summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--README1
-rw-r--r--build/.empty0
-rwxr-xr-xincludes/http.h6
-rw-r--r--includes/interface.h2
-rw-r--r--includes/powder.h21
-rw-r--r--src/http.c27
-rw-r--r--src/interface.c48
-rw-r--r--src/main.c14
-rw-r--r--src/misc.c12
-rw-r--r--src/powder.c6
11 files changed, 96 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index ccc72b8..65b90da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*.*.swp
-powder-64-sse3
+.directory
powder.def
-powder-debug
gmon.out
*.*.orig
+build/powder*
+build/stamps/*
diff --git a/README b/README
index e69de29..e965047 100644
--- a/README
+++ b/README
@@ -0,0 +1 @@
+Hello
diff --git a/build/.empty b/build/.empty
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/build/.empty
diff --git a/includes/http.h b/includes/http.h
index 2ad7ccc..af0971c 100755
--- a/includes/http.h
+++ b/includes/http.h
@@ -24,10 +24,10 @@ void http_init(char *proxy);
void http_done(void);
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);
-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_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);
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);
diff --git a/includes/interface.h b/includes/interface.h
index 986d5e4..de1c955 100644
--- a/includes/interface.h
+++ b/includes/interface.h
@@ -118,6 +118,8 @@ extern int svf_admin;
extern int svf_mod;
extern char svf_user[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_own;
diff --git a/includes/powder.h b/includes/powder.h
index 251605b..91d8f1f 100644
--- a/includes/powder.h
+++ b/includes/powder.h
@@ -510,13 +510,12 @@ static const part_type ptypes[PT_NUM] =
{"GNAR", PIXPACK(0xE5B73B), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"REPL", PIXPACK(0x259588), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B1357/S1357", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"MYST", PIXPACK(0x0C3C00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "B3458/S05678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
-
{"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL},
- {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE,TYPE_SOLID|PROP_LIFE, NULL},
- {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
- {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
- {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
- {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
+ {"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
+ {"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
+ {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
+ {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
+ {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE2, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description
};
@@ -675,10 +674,10 @@ static part_transition ptransitions[PT_NUM] =
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* BOYL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
- /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
- /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
- /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
- /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
+ /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
+ /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
+ /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
+ /* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
};
#undef IPL
#undef IPH
@@ -690,7 +689,7 @@ static part_transition ptransitions[PT_NUM] =
static int grule[NGOL][10] =
{
-// 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing
+// 0,1,2,3,4,5,6,7,8,STATES live=1 spawn=2 spawn&live=3 States are kind of how long until it dies, normal ones use two states(living,dead) for others the intermediate states live but do nothing
{0,0,0,0,0,0,0,0,0,2},//blank
{0,0,1,3,0,0,0,0,0,2},//GOL
{0,0,1,3,0,0,2,0,0,2},//HLIF
diff --git a/src/http.c b/src/http.c
index a68ea45..a881c73 100644
--- a/src/http.c
+++ b/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);
}
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;
int i;
@@ -690,7 +690,6 @@ void http_auth_headers(void *ctx, char *user, char *pass)
if (user)
{
- http_async_add_header(ctx, "X-Auth-User", user);
if (pass)
{
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);
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);
@@ -870,7 +878,7 @@ char *http_ret_text(int ret)
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;
char *data = NULL, *tmp, *p;
@@ -965,7 +973,7 @@ retry:
if (user)
{
- http_async_add_header(ctx, "X-Auth-User", user);
+ //http_async_add_header(ctx, "X-Auth-User", user);
if (pass)
{
md5_init(&md5);
@@ -1023,6 +1031,15 @@ retry:
http_async_add_header(ctx, "X-Auth-Hash", 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)
diff --git a/src/interface.c b/src/interface.c
index 6f3f0bc..e83adcb 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -25,7 +25,9 @@ int svf_login = 0;
int svf_admin = 0;
int svf_mod = 0;
char svf_user[64] = "";
+char svf_user_id[64] = "";
char svf_pass[64] = "";
+char svf_session_id[64] = "";
int svf_open = 0;
int svf_own = 0;
@@ -836,7 +838,7 @@ void login_ui(pixel *vid_buf)
res = http_multipart_post(
"http://" SERVER "/Login.api",
NULL, NULL, NULL,
- svf_user, svf_pass,
+ svf_user, svf_pass, NULL,
&err, NULL);
if (err != 200)
{
@@ -845,14 +847,27 @@ void login_ui(pixel *vid_buf)
free(res);
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_mod = 0;
}
- else if (!strcmp(res, "OK MOD"))
+ else if (!strncmp(nres, "MOD", 3))
{
svf_admin = 0;
svf_mod = 1;
@@ -874,6 +889,8 @@ void login_ui(pixel *vid_buf)
fail:
strcpy(svf_user, "");
strcpy(svf_pass, "");
+ strcpy(svf_user_id, "");
+ strcpy(svf_session_id, "");
svf_login = 0;
svf_own = 0;
svf_admin = 0;
@@ -2489,7 +2506,8 @@ int search_ui(pixel *vid_buf)
http = http_async_req_start(http, uri, NULL, 0, 1);
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);
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);
if (svf_login)
{
- http_auth_headers(http, svf_user, svf_pass);
- http_auth_headers(http_2, 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, 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_2 = time(NULL);
@@ -3483,7 +3503,7 @@ int execute_tagop(pixel *vid_buf, char *op, char *tag)
result = http_multipart_post(
uri,
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
free(uri);
@@ -3543,7 +3563,7 @@ void execute_save(pixel *vid_buf)
result = http_multipart_post(
"http://" SERVER "/Save.api",
names, parts, plens,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (svf_last)
@@ -3600,7 +3620,7 @@ int execute_delete(pixel *vid_buf, char *id)
result = http_multipart_post(
"http://" SERVER "/Delete.api",
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (status!=200)
@@ -3636,7 +3656,7 @@ void execute_submit(pixel *vid_buf, char *id, char *message)
result = http_multipart_post(
"http://" SERVER "/Comment.api",
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (status!=200)
@@ -3671,7 +3691,7 @@ int execute_report(pixel *vid_buf, char *id, char *reason)
result = http_multipart_post(
"http://" SERVER "/Report.api",
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (status!=200)
@@ -3706,7 +3726,7 @@ void execute_fav(pixel *vid_buf, char *id)
result = http_multipart_post(
"http://" SERVER "/Favourite.api",
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (status!=200)
@@ -3741,7 +3761,7 @@ int execute_vote(pixel *vid_buf, char *id, char *action)
result = http_multipart_post(
"http://" SERVER "/Vote.api",
names, parts, NULL,
- svf_user, svf_pass,
+ svf_user_id, /*svf_pass*/NULL, svf_session_id,
&status, NULL);
if (status!=200)
diff --git a/src/main.c b/src/main.c
index 6f7ee7b..e6f29b4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -492,6 +492,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
memset(vx, 0, sizeof(vx));
memset(vy, 0, sizeof(vy));
memset(pv, 0, sizeof(pv));
+ memset(photons, 0, sizeof(photons));
+ memset(wireless, 0, sizeof(wireless));
+ memset(gol2, 0, sizeof(gol2));
+ memset(portal, 0, sizeof(portal));
death = death2 = ISSPAWN1 = ISSPAWN2 = 0;
}
@@ -714,10 +718,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
ttv |= (d[p++]);
parts[i-1].tmp = ttv;
if(ptypes[parts[i-1].type].properties&PROP_LIFE && !parts[i-1].tmp)
- for(q = 1; q<NGOL ; q++){
- if(parts[i-1].type==goltype[q-1] && grule[q][9]==2)
- parts[i-1].tmp = grule[q][9]-1;
- }
+ for(q = 1; q<NGOL ; q++) {
+ if(parts[i-1].type==goltype[q-1] && grule[q][9]==2)
+ parts[i-1].tmp = grule[q][9]-1;
+ }
} else {
p+=2;
}
@@ -1509,7 +1513,7 @@ int main(int argc, char *argv[])
parts[i].type = parts[i].ctype;
parts[i].life = 0;
}
- }
+ }
else
{
for (nx = 0; nx<XRES/CELL; nx++)
diff --git a/src/misc.c b/src/misc.c
index 64c2af5..59ffc0e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -95,7 +95,9 @@ void save_presets(int do_update)
return;
fwrite(sig, 1, 4, f);
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);
tmp = cmode;
fwrite(&tmp, 1, 1, f);
@@ -144,7 +146,11 @@ void load_presets(void)
}
if (load_string(f, svf_user, 63))
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;
svf_login = !!svf_user[0];
if (fread(&tmp, 1, 1, f) != 1)
@@ -152,7 +158,7 @@ void load_presets(void)
sdl_scale = (tmp == 2) ? 2 : 1;
if (fread(&tmp, 1, 1, f) != 1)
goto fail;
- cmode = tmp%7;
+ cmode = tmp%CM_COUNT;
if (fread(&tmp, 1, 1, f) != 1)
goto fail;
svf_admin = tmp;
diff --git a/src/powder.c b/src/powder.c
index 873913c..b2932d1 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -664,9 +664,9 @@ inline int create_part(int p, int x, int y, int t)
parts[i].life = 50;
parts[i].tmp = 50;
}
- if(ptypes[t].properties&PROP_LIFE) {
+ if (ptypes[t].properties&PROP_LIFE) {
int r;
- for(r = 0;r<NGOL;r++)
+ for(r = 0; r<NGOL; r++)
if(t==goltype[r])
parts[i].tmp = grule[r+1][9] - 1;
}
@@ -1317,7 +1317,7 @@ void update_particles_i(pixel *vid, int start, int inc)
} else {
parts[r>>8].tmp --;
if(parts[r>>8].tmp<=0)
- parts[r>>8].type = PT_NONE;//using kill_part makes it not work
+ parts[r>>8].type = PT_NONE;//using kill_part makes it not work
}
}
}