Merge branch 'upstream' into dev
This commit is contained in:
commit
f97990fedd
@ -139,6 +139,7 @@ int gol[XRES][YRES];
|
|||||||
int gol2[XRES][YRES][NGOL+1];
|
int gol2[XRES][YRES][NGOL+1];
|
||||||
int SEC;
|
int SEC;
|
||||||
int SEC2;
|
int SEC2;
|
||||||
|
int console_mode;
|
||||||
int REPLACE_MODE;
|
int REPLACE_MODE;
|
||||||
int CURRENT_BRUSH;
|
int CURRENT_BRUSH;
|
||||||
int GRID_MODE;
|
int GRID_MODE;
|
||||||
|
@ -24,10 +24,10 @@ void http_init(char *proxy);
|
|||||||
void http_done(void);
|
void http_done(void);
|
||||||
|
|
||||||
char *http_simple_get(char *uri, int *ret, int *len);
|
char *http_simple_get(char *uri, int *ret, int *len);
|
||||||
char *http_auth_get(char *uri, char *user, char *pass, int *ret, int *len);
|
char *http_auth_get(char *uri, char *user, char *pass, char * session_id, int *ret, int *len);
|
||||||
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len);
|
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len);
|
||||||
|
|
||||||
void http_auth_headers(void *ctx, char *user, char *pass);
|
void http_auth_headers(void *ctx, char *user, char *pass, char * session_id);
|
||||||
|
|
||||||
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep);
|
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep);
|
||||||
void http_async_add_header(void *ctx, char *name, char *data);
|
void http_async_add_header(void *ctx, char *name, char *data);
|
||||||
@ -36,7 +36,7 @@ void http_async_get_length(void *ctx, int *total, int *done);
|
|||||||
char *http_async_req_stop(void *ctx, int *ret, int *len);
|
char *http_async_req_stop(void *ctx, int *ret, int *len);
|
||||||
void http_async_req_close(void *ctx);
|
void http_async_req_close(void *ctx);
|
||||||
|
|
||||||
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, int *ret, int *len);
|
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char * session_id, int *ret, int *len);
|
||||||
|
|
||||||
char *http_ret_text(int ret);
|
char *http_ret_text(int ret);
|
||||||
|
|
||||||
|
@ -118,6 +118,8 @@ extern int svf_admin;
|
|||||||
extern int svf_mod;
|
extern int svf_mod;
|
||||||
extern char svf_user[64];
|
extern char svf_user[64];
|
||||||
extern char svf_pass[64];
|
extern char svf_pass[64];
|
||||||
|
extern char svf_user_id[64];
|
||||||
|
extern char svf_session_id[64];
|
||||||
|
|
||||||
extern int svf_open;
|
extern int svf_open;
|
||||||
extern int svf_own;
|
extern int svf_own;
|
||||||
@ -224,5 +226,7 @@ void open_link(char *uri);
|
|||||||
|
|
||||||
int report_ui(pixel *vid_buf, char *save_id);
|
int report_ui(pixel *vid_buf, char *save_id);
|
||||||
|
|
||||||
|
char *console_ui(pixel *vid_buf, char error[255]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
27
src/http.c
27
src/http.c
@ -680,7 +680,7 @@ char *http_simple_get(char *uri, int *ret, int *len)
|
|||||||
return http_async_req_stop(ctx, ret, len);
|
return http_async_req_stop(ctx, ret, len);
|
||||||
}
|
}
|
||||||
static char hex[] = "0123456789abcdef";
|
static char hex[] = "0123456789abcdef";
|
||||||
void http_auth_headers(void *ctx, char *user, char *pass)
|
void http_auth_headers(void *ctx, char *user, char *pass, char *session_id)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int i;
|
int i;
|
||||||
@ -690,7 +690,6 @@ void http_auth_headers(void *ctx, char *user, char *pass)
|
|||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
http_async_add_header(ctx, "X-Auth-User", user);
|
|
||||||
if (pass)
|
if (pass)
|
||||||
{
|
{
|
||||||
md5_init(&md5);
|
md5_init(&md5);
|
||||||
@ -710,9 +709,18 @@ void http_auth_headers(void *ctx, char *user, char *pass)
|
|||||||
http_async_add_header(ctx, "X-Auth-Hash", tmp);
|
http_async_add_header(ctx, "X-Auth-Hash", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
if(session_id)
|
||||||
|
{
|
||||||
|
http_async_add_header(ctx, "X-Auth-User-Id", user);
|
||||||
|
http_async_add_header(ctx, "X-Auth-Session-Key", session_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
http_async_add_header(ctx, "X-Auth-User", user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *http_auth_get(char *uri, char *user, char *pass, int *ret, int *len)
|
char *http_auth_get(char *uri, char *user, char *pass, char *session_id, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
||||||
|
|
||||||
@ -870,7 +878,7 @@ char *http_ret_text(int ret)
|
|||||||
return "Unknown Status Code";
|
return "Unknown Status Code";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, int *ret, int *len)
|
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char *session_id, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
char *data = NULL, *tmp, *p;
|
char *data = NULL, *tmp, *p;
|
||||||
@ -965,7 +973,7 @@ retry:
|
|||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
http_async_add_header(ctx, "X-Auth-User", user);
|
//http_async_add_header(ctx, "X-Auth-User", user);
|
||||||
if (pass)
|
if (pass)
|
||||||
{
|
{
|
||||||
md5_init(&md5);
|
md5_init(&md5);
|
||||||
@ -1023,6 +1031,15 @@ retry:
|
|||||||
http_async_add_header(ctx, "X-Auth-Hash", tmp);
|
http_async_add_header(ctx, "X-Auth-Hash", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
if(session_id)
|
||||||
|
{
|
||||||
|
http_async_add_header(ctx, "X-Auth-User-Id", user);
|
||||||
|
http_async_add_header(ctx, "X-Auth-Session-Key", session_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
http_async_add_header(ctx, "X-Auth-User", user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
|
163
src/interface.c
163
src/interface.c
@ -25,7 +25,9 @@ int svf_login = 0;
|
|||||||
int svf_admin = 0;
|
int svf_admin = 0;
|
||||||
int svf_mod = 0;
|
int svf_mod = 0;
|
||||||
char svf_user[64] = "";
|
char svf_user[64] = "";
|
||||||
|
char svf_user_id[64] = "";
|
||||||
char svf_pass[64] = "";
|
char svf_pass[64] = "";
|
||||||
|
char svf_session_id[64] = "";
|
||||||
|
|
||||||
int svf_open = 0;
|
int svf_open = 0;
|
||||||
int svf_own = 0;
|
int svf_own = 0;
|
||||||
@ -836,7 +838,7 @@ void login_ui(pixel *vid_buf)
|
|||||||
res = http_multipart_post(
|
res = http_multipart_post(
|
||||||
"http://" SERVER "/Login.api",
|
"http://" SERVER "/Login.api",
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user, svf_pass, NULL,
|
||||||
&err, NULL);
|
&err, NULL);
|
||||||
if (err != 200)
|
if (err != 200)
|
||||||
{
|
{
|
||||||
@ -845,14 +847,27 @@ void login_ui(pixel *vid_buf)
|
|||||||
free(res);
|
free(res);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (res && !strncmp(res, "OK", 2))
|
if (res && !strncmp(res, "OK ", 3))
|
||||||
{
|
{
|
||||||
if (!strcmp(res, "OK ADMIN"))
|
char *s_id,*u_e,*nres;
|
||||||
|
s_id = strchr(res+3, ' ');
|
||||||
|
*(s_id++) = 0;
|
||||||
|
|
||||||
|
u_e = strchr(s_id, ' ');
|
||||||
|
*(u_e++) = 0;
|
||||||
|
|
||||||
|
strcpy(svf_user_id, res+3);
|
||||||
|
strcpy(svf_session_id, s_id);
|
||||||
|
nres = mystrdup(u_e);
|
||||||
|
|
||||||
|
printf("\n{%s} {%s} {%s}\n", svf_user_id, svf_session_id, nres);
|
||||||
|
|
||||||
|
if (!strncmp(nres, "ADMIN", 5))
|
||||||
{
|
{
|
||||||
svf_admin = 1;
|
svf_admin = 1;
|
||||||
svf_mod = 0;
|
svf_mod = 0;
|
||||||
}
|
}
|
||||||
else if (!strcmp(res, "OK MOD"))
|
else if (!strncmp(nres, "MOD", 3))
|
||||||
{
|
{
|
||||||
svf_admin = 0;
|
svf_admin = 0;
|
||||||
svf_mod = 1;
|
svf_mod = 1;
|
||||||
@ -874,6 +889,8 @@ void login_ui(pixel *vid_buf)
|
|||||||
fail:
|
fail:
|
||||||
strcpy(svf_user, "");
|
strcpy(svf_user, "");
|
||||||
strcpy(svf_pass, "");
|
strcpy(svf_pass, "");
|
||||||
|
strcpy(svf_user_id, "");
|
||||||
|
strcpy(svf_session_id, "");
|
||||||
svf_login = 0;
|
svf_login = 0;
|
||||||
svf_own = 0;
|
svf_own = 0;
|
||||||
svf_admin = 0;
|
svf_admin = 0;
|
||||||
@ -2489,7 +2506,8 @@ int search_ui(pixel *vid_buf)
|
|||||||
http = http_async_req_start(http, uri, NULL, 0, 1);
|
http = http_async_req_start(http, uri, NULL, 0, 1);
|
||||||
if (svf_login)
|
if (svf_login)
|
||||||
{
|
{
|
||||||
http_auth_headers(http, svf_user, svf_pass);
|
//http_auth_headers(http, svf_user, svf_pass);
|
||||||
|
http_auth_headers(http, svf_user_id, NULL, svf_session_id);
|
||||||
}
|
}
|
||||||
http_last_use = time(NULL);
|
http_last_use = time(NULL);
|
||||||
free(uri);
|
free(uri);
|
||||||
@ -2757,8 +2775,10 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
|||||||
http_2 = http_async_req_start(http_2, uri_2, NULL, 0, 1);
|
http_2 = http_async_req_start(http_2, uri_2, NULL, 0, 1);
|
||||||
if (svf_login)
|
if (svf_login)
|
||||||
{
|
{
|
||||||
http_auth_headers(http, svf_user, svf_pass);
|
//http_auth_headers(http, svf_user, svf_pass);
|
||||||
http_auth_headers(http_2, svf_user, svf_pass);
|
//http_auth_headers(http_2, svf_user, svf_pass);
|
||||||
|
http_auth_headers(http, svf_user_id, NULL, svf_session_id);
|
||||||
|
http_auth_headers(http_2, svf_user_id, NULL, svf_session_id);
|
||||||
}
|
}
|
||||||
http_last_use = time(NULL);
|
http_last_use = time(NULL);
|
||||||
http_last_use_2 = time(NULL);
|
http_last_use_2 = time(NULL);
|
||||||
@ -3483,7 +3503,7 @@ int execute_tagop(pixel *vid_buf, char *op, char *tag)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
uri,
|
uri,
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
free(uri);
|
free(uri);
|
||||||
@ -3543,7 +3563,7 @@ void execute_save(pixel *vid_buf)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Save.api",
|
"http://" SERVER "/Save.api",
|
||||||
names, parts, plens,
|
names, parts, plens,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (svf_last)
|
if (svf_last)
|
||||||
@ -3600,7 +3620,7 @@ int execute_delete(pixel *vid_buf, char *id)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Delete.api",
|
"http://" SERVER "/Delete.api",
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (status!=200)
|
if (status!=200)
|
||||||
@ -3636,7 +3656,7 @@ void execute_submit(pixel *vid_buf, char *id, char *message)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Comment.api",
|
"http://" SERVER "/Comment.api",
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (status!=200)
|
if (status!=200)
|
||||||
@ -3671,7 +3691,7 @@ int execute_report(pixel *vid_buf, char *id, char *reason)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Report.api",
|
"http://" SERVER "/Report.api",
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (status!=200)
|
if (status!=200)
|
||||||
@ -3706,7 +3726,7 @@ void execute_fav(pixel *vid_buf, char *id)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Favourite.api",
|
"http://" SERVER "/Favourite.api",
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (status!=200)
|
if (status!=200)
|
||||||
@ -3741,7 +3761,7 @@ int execute_vote(pixel *vid_buf, char *id, char *action)
|
|||||||
result = http_multipart_post(
|
result = http_multipart_post(
|
||||||
"http://" SERVER "/Vote.api",
|
"http://" SERVER "/Vote.api",
|
||||||
names, parts, NULL,
|
names, parts, NULL,
|
||||||
svf_user, svf_pass,
|
svf_user_id, /*svf_pass*/NULL, svf_session_id,
|
||||||
&status, NULL);
|
&status, NULL);
|
||||||
|
|
||||||
if (status!=200)
|
if (status!=200)
|
||||||
@ -3789,3 +3809,118 @@ void open_link(char *uri) {
|
|||||||
printf("Cannot open browser\n");
|
printf("Cannot open browser\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
struct command_history {
|
||||||
|
void *prev_command;
|
||||||
|
char *command;
|
||||||
|
};
|
||||||
|
typedef struct command_history command_history;
|
||||||
|
command_history *last_command = NULL;
|
||||||
|
char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands
|
||||||
|
int mx,my,b,bq,cc,ci = -1;
|
||||||
|
command_history *currentcommand;
|
||||||
|
ui_edit ed;
|
||||||
|
ed.x = 15;
|
||||||
|
ed.y = 210;
|
||||||
|
ed.w = XRES;
|
||||||
|
ed.nx = 1;
|
||||||
|
ed.def = "";
|
||||||
|
strcpy(ed.str, "");
|
||||||
|
ed.focus = 1;
|
||||||
|
ed.hide = 0;
|
||||||
|
ed.multiline = 0;
|
||||||
|
ed.cursor = 0;
|
||||||
|
//fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
|
||||||
|
while (!sdl_poll())
|
||||||
|
{
|
||||||
|
bq = b;
|
||||||
|
b = SDL_GetMouseState(&mx, &my);
|
||||||
|
mx /= sdl_scale;
|
||||||
|
my /= sdl_scale;
|
||||||
|
ed.focus = 1;
|
||||||
|
|
||||||
|
clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent?
|
||||||
|
draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE);
|
||||||
|
drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.1 (by cracker64)\n"
|
||||||
|
"Current commands are quit, set, reset, load\n"
|
||||||
|
"You can set type, temp, ctype, life, x, y, vx, vy using this format ('set life particle# 9001')\n"
|
||||||
|
"You can also use 'all' instead of a particle number to do it to everything\n"
|
||||||
|
"Reset works with pressure, velocity, sparks, temp (ex. 'reset pressure')\n"
|
||||||
|
"To load a save use load saveID (ex. load 1337)"
|
||||||
|
,255, 187, 187, 255);
|
||||||
|
|
||||||
|
cc = 0;
|
||||||
|
currentcommand = last_command;
|
||||||
|
while(cc < 10)
|
||||||
|
{
|
||||||
|
if(currentcommand==NULL)
|
||||||
|
break;
|
||||||
|
drawtext(vid_buf, 15, 175-(cc*12), currentcommand->command, 255, 255, 255, 255);
|
||||||
|
if(currentcommand->prev_command!=NULL)
|
||||||
|
{
|
||||||
|
if(cc<9) {
|
||||||
|
currentcommand = currentcommand->prev_command;
|
||||||
|
} else if(currentcommand->prev_command!=NULL) {
|
||||||
|
free(currentcommand->prev_command);
|
||||||
|
currentcommand->prev_command = NULL;
|
||||||
|
}
|
||||||
|
cc++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error)
|
||||||
|
drawtext(vid_buf, 15, 190, error,255, 187, 187, 255);
|
||||||
|
ui_edit_draw(vid_buf, &ed);
|
||||||
|
ui_edit_process(mx, my, b, &ed);
|
||||||
|
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
|
||||||
|
if (sdl_key==SDLK_RETURN)
|
||||||
|
{
|
||||||
|
currentcommand = malloc(sizeof(command_history));
|
||||||
|
memset(currentcommand, 0, sizeof(command_history));
|
||||||
|
currentcommand->prev_command = last_command;
|
||||||
|
currentcommand->command = mystrdup(ed.str);
|
||||||
|
last_command = currentcommand;
|
||||||
|
return ed.str;
|
||||||
|
}
|
||||||
|
if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE)
|
||||||
|
{
|
||||||
|
console_mode = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
|
||||||
|
{
|
||||||
|
ci += sdl_key==SDLK_UP?1:-1;
|
||||||
|
if(ci<-1)
|
||||||
|
ci = -1;
|
||||||
|
if(ci==-1)
|
||||||
|
{
|
||||||
|
strcpy(ed.str, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(last_command!=NULL) {
|
||||||
|
currentcommand = last_command;
|
||||||
|
for (cc = 0; cc<ci; cc++) {
|
||||||
|
if(currentcommand->prev_command==NULL)
|
||||||
|
ci = cc;
|
||||||
|
else
|
||||||
|
currentcommand = currentcommand->prev_command;
|
||||||
|
}
|
||||||
|
strcpy(ed.str, currentcommand->command);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ci = -1;
|
||||||
|
strcpy(ed.str, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
272
src/main.c
272
src/main.c
@ -1121,6 +1121,7 @@ int main(int argc, char *argv[])
|
|||||||
pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
pixel *pers_bg=calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
||||||
void *http_ver_check;
|
void *http_ver_check;
|
||||||
char *ver_data=NULL, *tmp;
|
char *ver_data=NULL, *tmp;
|
||||||
|
char error[255];
|
||||||
int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len;
|
int i, j, bq, fire_fc=0, do_check=0, old_version=0, http_ret=0, major, minor, old_ver_len;
|
||||||
#ifdef INTERNAL
|
#ifdef INTERNAL
|
||||||
int vs = 0;
|
int vs = 0;
|
||||||
@ -1487,8 +1488,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
|
if ((sdl_mod & (KMOD_RCTRL) )&&( sdl_mod & (KMOD_RALT)))
|
||||||
active_menu = 11;
|
active_menu = 11;
|
||||||
if (sdl_key==SDLK_INSERT || sdl_key==SDLK_BACKQUOTE)
|
if (sdl_key==SDLK_INSERT)// || sdl_key==SDLK_BACKQUOTE)
|
||||||
REPLACE_MODE = !REPLACE_MODE;
|
REPLACE_MODE = !REPLACE_MODE;
|
||||||
|
if (sdl_key==SDLK_BACKQUOTE)
|
||||||
|
{
|
||||||
|
console_mode = !console_mode;
|
||||||
|
hud_enable = !console_mode;
|
||||||
|
}
|
||||||
if (sdl_key=='g')
|
if (sdl_key=='g')
|
||||||
{
|
{
|
||||||
if (sdl_mod & (KMOD_SHIFT))
|
if (sdl_mod & (KMOD_SHIFT))
|
||||||
@ -1690,6 +1696,268 @@ int main(int argc, char *argv[])
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(console_mode)
|
||||||
|
{
|
||||||
|
int nx,ny;
|
||||||
|
char *console;
|
||||||
|
char *console2;
|
||||||
|
char *console3;
|
||||||
|
char *console4;
|
||||||
|
char *console5;
|
||||||
|
//char error[255] = "error!";
|
||||||
|
sys_pause = 1;
|
||||||
|
console = console_ui(vid_buf,error);
|
||||||
|
strcpy(error,"");
|
||||||
|
if(console && strcmp(console, "")!=0 && strncmp(console, " ", 1)!=0)
|
||||||
|
{
|
||||||
|
console2 = strtok(console, " ");
|
||||||
|
console3 = strtok(NULL, " ");
|
||||||
|
console4 = strtok(NULL, " ");
|
||||||
|
console5 = strtok(NULL, " ");
|
||||||
|
if(strcmp(console2, "quit")==0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if(strcmp(console2, "load")==0 && console3)
|
||||||
|
{
|
||||||
|
j = atoi(console3);
|
||||||
|
if(j)
|
||||||
|
{
|
||||||
|
open_ui(vid_buf, console3, NULL);
|
||||||
|
console_mode = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(console2, "reset")==0 && console3)
|
||||||
|
{
|
||||||
|
if(strcmp(console3, "pressure")==0)
|
||||||
|
{
|
||||||
|
for (nx = 0; nx<XRES/CELL; nx++)
|
||||||
|
for (ny = 0; ny<YRES/CELL; ny++)
|
||||||
|
{
|
||||||
|
pv[ny][nx] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(strcmp(console3, "velocity")==0)
|
||||||
|
{
|
||||||
|
for (nx = 0; nx<XRES/CELL; nx++)
|
||||||
|
for (ny = 0; ny<YRES/CELL; ny++)
|
||||||
|
{
|
||||||
|
vx[ny][nx] = 0;
|
||||||
|
vy[ny][nx] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(console3, "sparks")==0)
|
||||||
|
{
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type==PT_SPRK)
|
||||||
|
{
|
||||||
|
parts[i].type = parts[i].ctype;
|
||||||
|
parts[i].life = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(console3, "temp")==0)
|
||||||
|
{
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
parts[i].temp = ptypes[parts[i].type].heat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strcmp(console2, "set")==0 && console3 && console4 && console5)
|
||||||
|
{
|
||||||
|
if(strcmp(console3, "life")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].life = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].life = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "type")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].type = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].type = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "temp")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].temp = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].temp = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "tmp")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].tmp = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].tmp = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "x")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].x = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].x = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "y")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].y = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].y = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "ctype")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].ctype = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].ctype = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "vx")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].vx = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].vx = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strcmp(console3, "vy")==0)
|
||||||
|
{
|
||||||
|
if(strcmp(console4, "all")==0)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
for(i=0; i<NPART; i++)
|
||||||
|
{
|
||||||
|
if(parts[i].type)
|
||||||
|
parts[i].vy = j;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
i = atoi(console4);
|
||||||
|
if(parts[i].type)
|
||||||
|
{
|
||||||
|
j = atoi(console5);
|
||||||
|
parts[i].vy = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sprintf(error, "Invalid Command", console2);
|
||||||
|
}
|
||||||
|
if(!console_mode)
|
||||||
|
hud_enable = 1;
|
||||||
|
}
|
||||||
|
|
||||||
bq = b;
|
bq = b;
|
||||||
b = SDL_GetMouseState(&x, &y);
|
b = SDL_GetMouseState(&x, &y);
|
||||||
@ -1741,7 +2009,7 @@ int main(int argc, char *argv[])
|
|||||||
int tctype = parts[cr>>8].ctype;
|
int tctype = parts[cr>>8].ctype;
|
||||||
if (tctype>=PT_NUM)
|
if (tctype>=PT_NUM)
|
||||||
tctype = 0;
|
tctype = 0;
|
||||||
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
|
sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d, #%d", ptypes[cr&0xFF].name, ptypes[tctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life ,cr>>8);
|
||||||
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
|
//sprintf(heattext, "%s (%s), Pressure: %3.2f, Temp: %4.2f C, Life: %d", ptypes[cr&0xFF].name, ptypes[parts[cr>>8].ctype].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life);
|
||||||
} else {
|
} else {
|
||||||
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
|
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", ptypes[cr&0xFF].name, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
|
||||||
|
13
src/misc.c
13
src/misc.c
@ -5,6 +5,7 @@
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
#include "powder.h"
|
||||||
|
|
||||||
//Signum function
|
//Signum function
|
||||||
#if defined(WIN32) && !defined(__GNUC__)
|
#if defined(WIN32) && !defined(__GNUC__)
|
||||||
@ -95,7 +96,9 @@ void save_presets(int do_update)
|
|||||||
return;
|
return;
|
||||||
fwrite(sig, 1, 4, f);
|
fwrite(sig, 1, 4, f);
|
||||||
save_string(f, svf_user);
|
save_string(f, svf_user);
|
||||||
save_string(f, svf_pass);
|
//save_string(f, svf_pass);
|
||||||
|
save_string(f, svf_user_id);
|
||||||
|
save_string(f, svf_session_id);
|
||||||
fwrite(&tmp, 1, 1, f);
|
fwrite(&tmp, 1, 1, f);
|
||||||
tmp = cmode;
|
tmp = cmode;
|
||||||
fwrite(&tmp, 1, 1, f);
|
fwrite(&tmp, 1, 1, f);
|
||||||
@ -144,7 +147,11 @@ void load_presets(void)
|
|||||||
}
|
}
|
||||||
if (load_string(f, svf_user, 63))
|
if (load_string(f, svf_user, 63))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (load_string(f, svf_pass, 63))
|
//if (load_string(f, svf_pass, 63))
|
||||||
|
//goto fail;
|
||||||
|
if (load_string(f, svf_user_id, 63))
|
||||||
|
goto fail;
|
||||||
|
if (load_string(f, svf_session_id, 63))
|
||||||
goto fail;
|
goto fail;
|
||||||
svf_login = !!svf_user[0];
|
svf_login = !!svf_user[0];
|
||||||
if (fread(&tmp, 1, 1, f) != 1)
|
if (fread(&tmp, 1, 1, f) != 1)
|
||||||
@ -152,7 +159,7 @@ void load_presets(void)
|
|||||||
sdl_scale = (tmp == 2) ? 2 : 1;
|
sdl_scale = (tmp == 2) ? 2 : 1;
|
||||||
if (fread(&tmp, 1, 1, f) != 1)
|
if (fread(&tmp, 1, 1, f) != 1)
|
||||||
goto fail;
|
goto fail;
|
||||||
cmode = tmp%7;
|
cmode = tmp%CM_COUNT;
|
||||||
if (fread(&tmp, 1, 1, f) != 1)
|
if (fread(&tmp, 1, 1, f) != 1)
|
||||||
goto fail;
|
goto fail;
|
||||||
svf_admin = tmp;
|
svf_admin = tmp;
|
||||||
|
Reference in New Issue
Block a user