Moved Gravity identifiers, added gravity mode and air mode to save format

This commit is contained in:
Simon 2011-02-13 13:42:38 +00:00
parent d57c5ef5e0
commit b0b736d49e
2 changed files with 55 additions and 53 deletions

View File

@ -440,11 +440,11 @@ void *build_save(int *size, int x0, int y0, int w, int h)
//New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures //New file header uses PSv, replacing fuC. This is to detect if the client uses a new save format for temperatures
//This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error //This creates a problem for old clients, that display and "corrupt" error instead of a "newer version" error
c[0] = 0x50; //0x66; c[0] = 0x50; //0x66;
c[1] = 0x53; //0x75; c[1] = 0x53; //0x75;
c[2] = 0x76; //0x43; c[2] = 0x76; //0x43;
c[3] = legacy_enable|((sys_pause<<1)&0x02); c[3] = legacy_enable|((sys_pause<<1)&0x02)|((gravityMode<<2)&0x0C)|((airMode<<4)&0x70);
c[4] = SAVE_VERSION; c[4] = SAVE_VERSION;
c[5] = CELL; c[5] = CELL;
c[6] = bw; c[6] = bw;
@ -500,6 +500,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if (!sys_pause) { if (!sys_pause) {
sys_pause = (c[3]>>1)&0x01; sys_pause = (c[3]>>1)&0x01;
} }
if(ver>=46 && replace) {
gravityMode = ((c[3]>>2)&0x03);// | ((c[3]>>2)&0x01);
airMode = ((c[3]>>4)&0x07);// | ((c[3]>>4)&0x02) | ((c[3]>>4)&0x01);
}
} else { } else {
if (c[3]==1||c[3]==0) { if (c[3]==1||c[3]==0) {
legacy_enable = c[3]; legacy_enable = c[3];
@ -545,8 +549,10 @@ int parse_save(void *save, int size, int replace, int x0, int y0)
if (replace) if (replace)
{ {
gravityMode = 1; if(ver<46){
airMode = 1; gravityMode = 0;
airMode = 0;
}
memset(bmap, 0, sizeof(bmap)); memset(bmap, 0, sizeof(bmap));
memset(emap, 0, sizeof(emap)); memset(emap, 0, sizeof(emap));
memset(signs, 0, sizeof(signs)); memset(signs, 0, sizeof(signs));
@ -1174,7 +1180,7 @@ int main(int argc, char *argv[])
#ifdef BETA #ifdef BETA
int is_beta = 0; int is_beta = 0;
#endif #endif
char uitext[255] = ""; char uitext[512] = "";
char heattext[128] = ""; char heattext[128] = "";
char coordtext[13] = ""; char coordtext[13] = "";
int currentTime = 0; int currentTime = 0;
@ -1691,10 +1697,10 @@ int main(int argc, char *argv[])
default: default:
gravityMode = 0; gravityMode = 0;
case 0: case 0:
strcpy(itc_msg, "Gravity: Off"); strcpy(itc_msg, "Gravity: Vertical");
break; break;
case 1: case 1:
strcpy(itc_msg, "Gravity: Vertical"); strcpy(itc_msg, "Gravity: Off");
break; break;
case 2: case 2:
strcpy(itc_msg, "Gravity: Radial"); strcpy(itc_msg, "Gravity: Radial");
@ -1702,33 +1708,32 @@ int main(int argc, char *argv[])
} }
} }
if (sdl_key=='y')
if (sdl_key=='y') {
{ ++airMode;
++airMode; itc = 52;
itc = 52;
switch (airMode) switch (airMode)
{ {
default: default:
airMode = 0; airMode = 0;
case 0: case 0:
strcpy(itc_msg, "Air: On"); strcpy(itc_msg, "Air: On");
break; break;
case 1: case 1:
strcpy(itc_msg, "Air: Pressure Off"); strcpy(itc_msg, "Air: Pressure Off");
break; break;
case 2: case 2:
strcpy(itc_msg, "Air: Velocity Off"); strcpy(itc_msg, "Air: Velocity Off");
break; break;
case 3: case 3:
strcpy(itc_msg, "Air: Off"); strcpy(itc_msg, "Air: Off");
break; break;
case 4: case 4:
strcpy(itc_msg, "Air: No Update"); strcpy(itc_msg, "Air: No Update");
break; break;
} }
} }
if (sdl_key=='t') if (sdl_key=='t')
VINE_MODE = !VINE_MODE; VINE_MODE = !VINE_MODE;
@ -2277,7 +2282,7 @@ int main(int argc, char *argv[])
svf_name[0] = 0; svf_name[0] = 0;
svf_tags[0] = 0; svf_tags[0] = 0;
svf_description[0] = 0; svf_description[0] = 0;
gravityMode = 1; gravityMode = 0;
airMode = 0; airMode = 0;
death = death2 = 0; death = death2 = 0;
isplayer2 = 0; isplayer2 = 0;
@ -2656,10 +2661,10 @@ int main(int argc, char *argv[])
} }
#ifdef BETA #ifdef BETA
sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); sprintf(uitext, "Version %d Beta %d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode);
#else #else
if (DEBUG_MODE) if (DEBUG_MODE)
sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS,GENERATION); sprintf(uitext, "Version %d.%d FPS:%d Parts:%d Generation:%d Gravity:%d Air:%d", SAVE_VERSION, MINOR_VERSION, FPSB, NUM_PARTS, GENERATION, gravityMode, airMode);
else else
sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB); sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPSB);
#endif #endif

View File

@ -12,7 +12,7 @@ float player2[27];
particle *parts; particle *parts;
particle *cb_parts; particle *cb_parts;
int gravityMode = 1; // starts enabled in "vertical" mode... int gravityMode = 0; // starts enabled in "vertical" mode...
int airMode = 0; int airMode = 0;
@ -1442,21 +1442,18 @@ void update_particles_i(pixel *vid, int start, int inc)
//Gravity mode by Moach //Gravity mode by Moach
switch (gravityMode) switch (gravityMode)
{ {
default: default:
case 0: case 0:
pGravX = pGravY = 0.0f; pGravX = 0.0f;
break; pGravY = ptypes[t].gravity;
case 1: break;
pGravX = 0.0f; case 1:
pGravY = ptypes[t].gravity; pGravX = pGravY = 0.0f;
break; break;
case 2: case 2:
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR));
pGravD = 0.01f - hypotf((x - XCNTR), (y - YCNTR)); pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
pGravX = ptypes[t].gravity * ((float)(x - XCNTR) / pGravD);
pGravY = ptypes[t].gravity * ((float)(y - YCNTR) / pGravD);
} }
parts[i].vx *= ptypes[t].loss; parts[i].vx *= ptypes[t].loss;