An additional crapload of formatting changes

git-svn-id: https://svn.eduke32.com/eduke32@335 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-11-15 01:16:55 +00:00
parent a289704d10
commit 628ef41cc4
23 changed files with 29182 additions and 27180 deletions

View file

@ -61,11 +61,13 @@ void dointerpolations(long smoothratio) //Stick at beginning of drawscreen
{ {
long i, j, odelta, ndelta; long i, j, odelta, ndelta;
ndelta = 0; j = 0; ndelta = 0;
j = 0;
for (i=numinterpolations-1;i>=0;i--) for (i=numinterpolations-1;i>=0;i--)
{ {
bakipos[i] = *curipos[i]; bakipos[i] = *curipos[i];
odelta = ndelta; ndelta = (*curipos[i])-oldipos[i]; odelta = ndelta;
ndelta = (*curipos[i])-oldipos[i];
if (odelta != ndelta) j = mulscale16(ndelta,smoothratio); if (odelta != ndelta) j = mulscale16(ndelta,smoothratio);
*curipos[i] = oldipos[i]+j; *curipos[i] = oldipos[i]+j;
} }
@ -121,11 +123,14 @@ void addweaponnoswitch(struct player_struct *p, short weapon)
case HANDBOMB_WEAPON: case HANDBOMB_WEAPON:
break; break;
case SHOTGUN_WEAPON: case SHOTGUN_WEAPON:
stopspritesound(SHOTGUN_COCK,p->i);break; stopspritesound(SHOTGUN_COCK,p->i);
break;
case PISTOL_WEAPON: case PISTOL_WEAPON:
stopspritesound(INSERT_CLIP,p->i);break; stopspritesound(INSERT_CLIP,p->i);
break;
default: default:
stopspritesound(SELECT_WEAPON,p->i);break; stopspritesound(SELECT_WEAPON,p->i);
break;
} }
switch (weapon) switch (weapon)
{ {
@ -135,11 +140,14 @@ void addweaponnoswitch(struct player_struct *p, short weapon)
case HANDBOMB_WEAPON: case HANDBOMB_WEAPON:
break; break;
case SHOTGUN_WEAPON: case SHOTGUN_WEAPON:
spritesound(SHOTGUN_COCK,p->i);break; spritesound(SHOTGUN_COCK,p->i);
break;
case PISTOL_WEAPON: case PISTOL_WEAPON:
spritesound(INSERT_CLIP,p->i);break; spritesound(INSERT_CLIP,p->i);
break;
default: default:
spritesound(SELECT_WEAPON,p->i);break; spritesound(SELECT_WEAPON,p->i);
break;
} }
} }
@ -329,7 +337,8 @@ void hitradius(short i, long r, long hp1, long hp2, long hp3, long hp4)
{ {
tempshort[0] = s->sectnum; tempshort[0] = s->sectnum;
dasect = s->sectnum; dasect = s->sectnum;
sectcnt = 0; sectend = 1; sectcnt = 0;
sectend = 1;
do do
{ {
@ -1654,7 +1663,10 @@ void movestandables(void)
s->xrepeat = j; s->xrepeat = j;
j = s->yrepeat-(TRAND&7); j = s->yrepeat-(TRAND&7);
if (j < 4) { KILLIT(i); } if (j < 4)
{
KILLIT(i);
}
s->yrepeat = j; s->yrepeat = j;
} }
if (s->picnum == BOX) if (s->picnum == BOX)
@ -1717,7 +1729,9 @@ void movestandables(void)
x = s->extra; x = s->extra;
s->extra = 1; s->extra = 1;
l = s->ang; l = s->ang;
IFHIT { hittype[i].temp_data[6] = 3; T3 = 16; } IFHIT { hittype[i].temp_data[6] = 3;
T3 = 16;
}
s->extra = x; s->extra = x;
s->ang = l; s->ang = l;
} }
@ -1733,7 +1747,8 @@ void movestandables(void)
l = s->ang; l = s->ang;
s->ang = T6; s->ang = T6;
T4 = s->x;T5 = s->y; T4 = s->x;
T5 = s->y;
s->x += sintable[(T6+512)&2047]>>9; s->x += sintable[(T6+512)&2047]>>9;
s->y += sintable[(T6)&2047]>>9; s->y += sintable[(T6)&2047]>>9;
s->z -= (3<<8); s->z -= (3<<8);
@ -1771,7 +1786,8 @@ void movestandables(void)
} }
} }
T1++; T1++;
s->x = T4;s->y = T5; s->x = T4;
s->y = T5;
s->z += (3<<8); s->z += (3<<8);
setsprite(i,s->x,s->y,s->z); setsprite(i,s->x,s->y,s->z);
T4 = 0; T4 = 0;
@ -1789,7 +1805,8 @@ void movestandables(void)
T2++; T2++;
T4 = s->x;T5 = s->y; T4 = s->x;
T5 = s->y;
s->x += sintable[(T6+512)&2047]>>9; s->x += sintable[(T6+512)&2047]>>9;
s->y += sintable[(T6)&2047]>>9; s->y += sintable[(T6)&2047]>>9;
s->z -= (3<<8); s->z -= (3<<8);
@ -1797,7 +1814,8 @@ void movestandables(void)
x = hitasprite(i,&m); x = hitasprite(i,&m);
s->x = T4;s->y = T5; s->x = T4;
s->y = T5;
s->z += (3<<8); s->z += (3<<8);
setsprite(i,s->x,s->y,s->z); setsprite(i,s->x,s->y,s->z);
@ -2037,10 +2055,12 @@ DETONATE:
goto BOLT; goto BOLT;
} }
switchpicnum = s->picnum; switchpicnum = s->picnum;
if ((s->picnum > SIDEBOLT1) && (s->picnum <= SIDEBOLT1+3)) { if ((s->picnum > SIDEBOLT1) && (s->picnum <= SIDEBOLT1+3))
{
switchpicnum = SIDEBOLT1; switchpicnum = SIDEBOLT1;
} }
if ((s->picnum > BOLT1) && (s->picnum <= BOLT1+3)) { if ((s->picnum > BOLT1) && (s->picnum <= BOLT1+3))
{
switchpicnum = BOLT1; switchpicnum = BOLT1;
} }
@ -2346,7 +2366,8 @@ void bounce(short i)
hitsect = s->sectnum; hitsect = s->sectnum;
k = sector[hitsect].wallptr; l = wall[k].point2; k = sector[hitsect].wallptr;
l = wall[k].point2;
daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y); daang = getangle(wall[l].x-wall[k].x,wall[l].y-wall[k].y);
if (s->z < (hittype[i].floorz+hittype[i].ceilingz)>>1) if (s->z < (hittype[i].floorz+hittype[i].ceilingz)>>1)
@ -2444,7 +2465,9 @@ void moveweapons(void)
if (thisprojectile[i].drop) s->zvel=s->zvel-thisprojectile[i].drop; if (thisprojectile[i].drop) s->zvel=s->zvel-thisprojectile[i].drop;
dax = s->x; day = s->y; daz = s->z; dax = s->x;
day = s->y;
daz = s->z;
if (thisprojectile[i].workslike & PROJECTILE_FLAG_TIMED && thisprojectile[i].range > 0) if (thisprojectile[i].workslike & PROJECTILE_FLAG_TIMED && thisprojectile[i].range > 0)
{ {
@ -2529,7 +2552,10 @@ void moveweapons(void)
if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256)
j = 49152|s->yvel; j = 49152|s->yvel;
if (s->sectnum < 0) { KILLIT(i); } if (s->sectnum < 0)
{
KILLIT(i);
}
if ((j&49152) != 49152) if ((j&49152) != 49152)
if (!(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS)) if (!(thisprojectile[i].workslike & PROJECTILE_FLAG_BOUNCESOFFWALLS))
@ -2898,7 +2924,9 @@ void moveweapons(void)
ll = s->zvel; ll = s->zvel;
} }
dax = s->x; day = s->y; daz = s->z; dax = s->x;
day = s->y;
daz = s->z;
getglobalz(i); getglobalz(i);
qq = CLIPMASK1; qq = CLIPMASK1;
@ -2922,7 +2950,10 @@ void moveweapons(void)
if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256)
j = 49152|s->yvel; j = 49152|s->yvel;
if (s->sectnum < 0) { KILLIT(i); } if (s->sectnum < 0)
{
KILLIT(i);
}
if ((j&49152) != 49152) if ((j&49152) != 49152)
if (s->picnum != FREEZEBLAST) if (s->picnum != FREEZEBLAST)
@ -3093,7 +3124,11 @@ void moveweapons(void)
{ {
if (s->zvel > 0) if (s->zvel > 0)
spawn(i,EXPLOSION2BOT); spawn(i,EXPLOSION2BOT);
else { sprite[k].cstat |= 8; sprite[k].z += (48<<8); } else
{
sprite[k].cstat |= 8;
sprite[k].z += (48<<8);
}
} }
} }
@ -3110,7 +3145,10 @@ void moveweapons(void)
if ((j&49152) == 16384) if ((j&49152) == 16384)
{ {
if (s->zvel < 0) if (s->zvel < 0)
{ sprite[k].cstat |= 8; sprite[k].z += (72<<8); } {
sprite[k].cstat |= 8;
sprite[k].z += (72<<8);
}
} }
} }
@ -3332,7 +3370,8 @@ void movetransports(void)
|| (sprite[j].picnum == COMMANDER) || (sprite[j].picnum == COMMANDER)
|| (sprite[j].picnum == OCTABRAIN) || (sprite[j].picnum == OCTABRAIN)
|| ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum >= GREENSLIME+7)) || ((sprite[j].picnum >= GREENSLIME) && (sprite[j].picnum >= GREENSLIME+7))
) { )
{
if (sprite[j].extra > 0) if (sprite[j].extra > 0)
goto JBOLT; goto JBOLT;
} }
@ -3515,7 +3554,8 @@ void moveactors(void)
hittype[i].bposy = s->y; hittype[i].bposy = s->y;
hittype[i].bposz = s->z; hittype[i].bposz = s->z;
switchpicnum=s->picnum; switchpicnum=s->picnum;
if ((s->picnum > GREENSLIME)&&(s->picnum <= GREENSLIME+7)) { if ((s->picnum > GREENSLIME)&&(s->picnum <= GREENSLIME+7))
{
switchpicnum = GREENSLIME; switchpicnum = GREENSLIME;
} }
switch (dynamictostatic[switchpicnum]) switch (dynamictostatic[switchpicnum])
@ -3612,7 +3652,10 @@ void moveactors(void)
else else
{ {
T1++; T1++;
if (T1 > 1) { KILLIT(i); } if (T1 > 1)
{
KILLIT(i);
}
else s->ang = (TRAND&2047); else s->ang = (TRAND&2047);
} }
if (s->xvel < 128) if (s->xvel < 128)
@ -3875,11 +3918,18 @@ void moveactors(void)
{ {
l = dist(&sprite[j],s); l = dist(&sprite[j],s);
if (l <= 1524) { if (t[0] == 1) t[0] = 0; else t[0] = 5; } if (l <= 1524)
{
if (t[0] == 1) t[0] = 0;
else t[0] = 5;
}
else else
{ {
// Control speed here // Control speed here
if (l > 1524) { if (s->xvel < 256) s->xvel += 32; } if (l > 1524)
{
if (s->xvel < 256) s->xvel += 32;
}
else else
{ {
if (s->xvel > 0) s->xvel -= 16; if (s->xvel > 0) s->xvel -= 16;
@ -4142,7 +4192,9 @@ void moveactors(void)
if (j == FREEZEBLAST) if (j == FREEZEBLAST)
{ {
spritesound(SOMETHINGFROZE,i); t[0] = -5 ; t[3] = 0 ; spritesound(SOMETHINGFROZE,i);
t[0] = -5 ;
t[3] = 0 ;
goto BOLT; goto BOLT;
} }
@ -4206,7 +4258,8 @@ void moveactors(void)
{ {
t[0] = -1; t[0] = -1;
x = ldist(s,&sprite[t[5]]); x = ldist(s,&sprite[t[5]]);
if (x < 768) { if (x < 768)
{
sprite[t[5]].xrepeat = 0; sprite[t[5]].xrepeat = 0;
// JBF 20041129: a slimer eating another enemy really ought // JBF 20041129: a slimer eating another enemy really ought
@ -4500,11 +4553,14 @@ DETONATEB:
switch (dynamictostatic[s->picnum]) switch (dynamictostatic[s->picnum])
{ {
case HEAVYHBOMB__STATIC: case HEAVYHBOMB__STATIC:
m = pipebombblastradius;break; m = pipebombblastradius;
break;
case MORTER__STATIC: case MORTER__STATIC:
m = morterblastradius;break; m = morterblastradius;
break;
case BOUNCEMINE__STATIC: case BOUNCEMINE__STATIC:
m = bouncemineblastradius;break; m = bouncemineblastradius;
break;
} }
hitradius(i, m,x>>2,x>>1,x-(x>>2),x); hitradius(i, m,x>>2,x>>1,x-(x>>2),x);
@ -4817,13 +4873,16 @@ void moveexplosions(void) // STATNUM 5
hittype[i].bposy = s->y; hittype[i].bposy = s->y;
hittype[i].bposz = s->z; hittype[i].bposz = s->z;
switchpicnum = s->picnum; switchpicnum = s->picnum;
if ((s->picnum > NUKEBUTTON)&&(s->picnum <= NUKEBUTTON+3)) { if ((s->picnum > NUKEBUTTON)&&(s->picnum <= NUKEBUTTON+3))
{
switchpicnum = NUKEBUTTON; switchpicnum = NUKEBUTTON;
} }
if ((s->picnum > GLASSPIECES)&&(s->picnum <= GLASSPIECES+2)) { if ((s->picnum > GLASSPIECES)&&(s->picnum <= GLASSPIECES+2))
{
switchpicnum = GLASSPIECES; switchpicnum = GLASSPIECES;
} }
if (s->picnum ==INNERJAW+1) { if (s->picnum ==INNERJAW+1)
{
switchpicnum--; switchpicnum--;
} }
if ((s->picnum == MONEY+1) || (s->picnum == MAIL+1) || (s->picnum == PAPER+1)) if ((s->picnum == MONEY+1) || (s->picnum == MAIL+1) || (s->picnum == PAPER+1))
@ -4924,7 +4983,8 @@ void moveexplosions(void) // STATNUM 5
l = getflorzofslope(sect,s->x,s->y)-s->z; l = getflorzofslope(sect,s->x,s->y)-s->z;
if( l > (16<<8) ) KILLIT(i); if( l > (16<<8) ) KILLIT(i);
} }
else */ if (!issoundplaying(i,ITEM_SPLASH)) else */
if (!issoundplaying(i,ITEM_SPLASH))
spritesound(ITEM_SPLASH,i); spritesound(ITEM_SPLASH,i);
} }
if (t[0] == 3) if (t[0] == 3)
@ -5045,7 +5105,10 @@ void moveexplosions(void) // STATNUM 5
if (t[5] < 30*10) if (t[5] < 30*10)
t[5]++; t[5]++;
else { KILLIT(i); } else
{
KILLIT(i);
}
if (s->zvel > 1024 && s->zvel < 1280) if (s->zvel > 1024 && s->zvel < 1280)
@ -5097,8 +5160,14 @@ void moveexplosions(void) // STATNUM 5
{ {
if (t[2] == 0) if (t[2] == 0)
{ {
if (s->sectnum == -1) { KILLIT(i); } if (s->sectnum == -1)
if ((sector[s->sectnum].floorstat&2)) { KILLIT(i); } {
KILLIT(i);
}
if ((sector[s->sectnum].floorstat&2))
{
KILLIT(i);
}
t[2]++; t[2]++;
} }
l = getflorzofslope(s->sectnum,s->x,s->y); l = getflorzofslope(s->sectnum,s->x,s->y);
@ -5113,7 +5182,12 @@ void moveexplosions(void) // STATNUM 5
t[0]++; t[0]++;
if (t[1] > 20) KILLIT(i); if (t[1] > 20) KILLIT(i);
} }
else { s->picnum = JIBS6; t[0] = 0; t[1] = 0; } else
{
s->picnum = JIBS6;
t[0] = 0;
t[1] = 0;
}
} }
goto BOLT; goto BOLT;
@ -5124,7 +5198,10 @@ void moveexplosions(void) // STATNUM 5
if (t[0] == 0) if (t[0] == 0)
{ {
t[0] = 1; t[0] = 1;
if (sector[sect].floorstat&2) { KILLIT(i); } if (sector[sect].floorstat&2)
{
KILLIT(i);
}
else insertspriteq(i); else insertspriteq(i);
} }
@ -6527,7 +6604,10 @@ void moveeffectors(void) //STATNUM 3
break; break;
j = nextspritesect[j]; j = nextspritesect[j];
} }
if (j == -1) { KILLIT(i); } if (j == -1)
{
KILLIT(i);
}
else s->shade=1; else s->shade=1;
} }
@ -7517,7 +7597,10 @@ void moveeffectors(void) //STATNUM 3
break; break;
case 130: case 130:
if (t[0] > 80) { KILLIT(i); } if (t[0] > 80)
{
KILLIT(i);
}
else t[0]++; else t[0]++;
x = sc->floorz-sc->ceilingz; x = sc->floorz-sc->ceilingz;
@ -7533,7 +7616,10 @@ void moveeffectors(void) //STATNUM 3
} }
break; break;
case 131: case 131:
if (t[0] > 40) { KILLIT(i); } if (t[0] > 40)
{
KILLIT(i);
}
else t[0]++; else t[0]++;
x = sc->floorz-sc->ceilingz; x = sc->floorz-sc->ceilingz;

View file

@ -259,7 +259,8 @@ void playanm(char *fn,char t)
extern char restorepalette; extern char restorepalette;
if (KB_KeyWaiting()) if (KB_KeyWaiting())
goto ENDOFANIMLOOP; goto ENDOFANIMLOOP;
handleevents(); getpackets(); handleevents();
getpackets();
if (restorepalette == 1) if (restorepalette == 1)
setgamepalette(&ps[myconnectindex],tempbuf,2); setgamepalette(&ps[myconnectindex],tempbuf,2);
} }

File diff suppressed because it is too large Load diff

View file

@ -97,7 +97,10 @@ int32 ScreenBPP = 8;
#endif #endif
int32 ForceSetup = 1; int32 ForceSetup = 1;
static char setupfilename[BMAX_PATH]={SETUPFILENAME}; static char setupfilename[BMAX_PATH]=
{
SETUPFILENAME
};
int32 scripthandle = -1; int32 scripthandle = -1;
static int32 setupread=0; static int32 setupread=0;
@ -185,7 +188,8 @@ int32 CONFIG_AnalogNameToNum(char * func)
char * CONFIG_AnalogNumToName(int32 func) char * CONFIG_AnalogNumToName(int32 func)
{ {
switch (func) { switch (func)
{
case analog_turning: case analog_turning:
return "analog_turning"; return "analog_turning";
case analog_strafing: case analog_strafing:
@ -277,7 +281,8 @@ void CONFIG_SetDefaults(void)
// JBF 20031211 // JBF 20031211
memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys)); memset(KeyboardKeys, 0xff, sizeof(KeyboardKeys));
for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3) { for (i=0; i < (int32)(sizeof(keydefaults)/sizeof(keydefaults[0])); i+=3)
{
f = CONFIG_FunctionNameToNum(keydefaults[i+0]); f = CONFIG_FunctionNameToNum(keydefaults[i+0]);
if (f == -1) continue; if (f == -1) continue;
KeyboardKeys[f][0] = KB_StringToScanCode(keydefaults[i+1]); KeyboardKeys[f][0] = KB_StringToScanCode(keydefaults[i+1]);
@ -288,7 +293,8 @@ void CONFIG_SetDefaults(void)
} }
memset(MouseFunctions, -1, sizeof(MouseFunctions)); memset(MouseFunctions, -1, sizeof(MouseFunctions));
for (i=0; i<MAXMOUSEBUTTONS; i++) { for (i=0; i<MAXMOUSEBUTTONS; i++)
{
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]); MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse); CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse);
if (i>=4) continue; if (i>=4) continue;
@ -297,7 +303,8 @@ void CONFIG_SetDefaults(void)
} }
memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions));
for (i=0; i<MAXMOUSEAXES; i++) { for (i=0; i<MAXMOUSEAXES; i++)
{
MouseAnalogueScale[i] = 65536; MouseAnalogueScale[i] = 65536;
CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse); CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse);
@ -312,7 +319,8 @@ void CONFIG_SetDefaults(void)
CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY); CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY);
memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); memset(JoystickFunctions, -1, sizeof(JoystickFunctions));
for (i=0; i<MAXJOYBUTTONS; i++) { for (i=0; i<MAXJOYBUTTONS; i++)
{
JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]); JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]); JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
CONTROL_MapButton(JoystickFunctions[i][0], i, 0, controldevice_joystick); CONTROL_MapButton(JoystickFunctions[i][0], i, 0, controldevice_joystick);
@ -320,7 +328,8 @@ void CONFIG_SetDefaults(void)
} }
memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions));
for (i=0; i<MAXJOYAXES; i++) { for (i=0; i<MAXJOYAXES; i++)
{
JoystickAnalogueScale[i] = 65536; JoystickAnalogueScale[i] = 65536;
JoystickAnalogueDead[i] = 1000; JoystickAnalogueDead[i] = 1000;
JoystickAnalogueSaturate[i] = 9500; JoystickAnalogueSaturate[i] = 9500;
@ -415,12 +424,14 @@ void CONFIG_SetupMouse(void)
for (i=0;i<MAXMOUSEBUTTONS;i++) for (i=0;i<MAXMOUSEBUTTONS;i++)
{ {
Bsprintf(str,"MouseButton%ld",i); temp[0] = 0; Bsprintf(str,"MouseButton%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle,"Controls", str,temp)) if (!SCRIPT_GetString(scripthandle,"Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(temp); MouseFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
Bsprintf(str,"MouseButtonClicked%ld",i); temp[0] = 0; Bsprintf(str,"MouseButtonClicked%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle,"Controls", str,temp)) if (!SCRIPT_GetString(scripthandle,"Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp); MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -429,17 +440,20 @@ void CONFIG_SetupMouse(void)
// map over the axes // map over the axes
for (i=0;i<MAXMOUSEAXES;i++) for (i=0;i<MAXMOUSEAXES;i++)
{ {
Bsprintf(str,"MouseAnalogAxes%ld",i); temp[0] = 0; Bsprintf(str,"MouseAnalogAxes%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0)
MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
Bsprintf(str,"MouseDigitalAxes%ld_0",i); temp[0] = 0; Bsprintf(str,"MouseDigitalAxes%ld_0",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
Bsprintf(str,"MouseDigitalAxes%ld_1",i); temp[0] = 0; Bsprintf(str,"MouseDigitalAxes%ld_1",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -487,12 +501,14 @@ void CONFIG_SetupJoystick(void)
for (i=0;i<MAXJOYBUTTONS;i++) for (i=0;i<MAXJOYBUTTONS;i++)
{ {
Bsprintf(str,"JoystickButton%ld",i); temp[0] = 0; Bsprintf(str,"JoystickButton%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle,"Controls", str,temp)) if (!SCRIPT_GetString(scripthandle,"Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(temp); JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
Bsprintf(str,"JoystickButtonClicked%ld",i); temp[0] = 0; Bsprintf(str,"JoystickButtonClicked%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle,"Controls", str,temp)) if (!SCRIPT_GetString(scripthandle,"Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp); JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -501,17 +517,20 @@ void CONFIG_SetupJoystick(void)
// map over the axes // map over the axes
for (i=0;i<MAXJOYAXES;i++) for (i=0;i<MAXJOYAXES;i++)
{ {
Bsprintf(str,"JoystickAnalogAxes%ld",i); temp[0] = 0; Bsprintf(str,"JoystickAnalogAxes%ld",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0)
JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp);
Bsprintf(str,"JoystickDigitalAxes%ld_0",i); temp[0] = 0; Bsprintf(str,"JoystickDigitalAxes%ld_0",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp);
Bsprintf(str,"JoystickDigitalAxes%ld_1",i); temp[0] = 0; Bsprintf(str,"JoystickDigitalAxes%ld_1",i);
temp[0] = 0;
if (!SCRIPT_GetString(scripthandle, "Controls", str,temp)) if (!SCRIPT_GetString(scripthandle, "Controls", str,temp))
if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0) if (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -559,12 +578,35 @@ void readsavenames(void)
{ {
fn[4] = i+'0'; fn[4] = i+'0';
if ((fil = Bfopen(fn,"rb")) == NULL) continue; if ((fil = Bfopen(fn,"rb")) == NULL) continue;
if (dfread(&j,sizeof(long),1,fil) != 1) { Bfclose(fil); continue; } if (dfread(&j,sizeof(long),1,fil) != 1)
if (dfread(g_szBuf,j,1,fil) != 1) { Bfclose(fil); continue; } {
if (dfread(&dummy,4,1,fil) != 1) { Bfclose(fil); continue; } Bfclose(fil);
if (dummy != BYTEVERSION) { Bfclose(fil); continue; } continue;
if (dfread(&dummy,4,1,fil) != 1) { Bfclose(fil); continue; } }
if (dfread(&ud.savegame[i][0],19,1,fil) != 1) { ud.savegame[i][0] = 0; } if (dfread(g_szBuf,j,1,fil) != 1)
{
Bfclose(fil);
continue;
}
if (dfread(&dummy,4,1,fil) != 1)
{
Bfclose(fil);
continue;
}
if (dummy != BYTEVERSION)
{
Bfclose(fil);
continue;
}
if (dfread(&dummy,4,1,fil) != 1)
{
Bfclose(fil);
continue;
}
if (dfread(&ud.savegame[i][0],19,1,fil) != 1)
{
ud.savegame[i][0] = 0;
}
Bfclose(fil); Bfclose(fil);
} }
} }
@ -615,7 +657,8 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(scripthandle, "Screen Setup", "Shadows",&ud.shadows); SCRIPT_GetNumber(scripthandle, "Screen Setup", "Shadows",&ud.shadows);
if (!NAM) { if (!NAM)
{
SCRIPT_GetString(scripthandle, "Screen Setup","Password",&ud.pwlockout[0]); SCRIPT_GetString(scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
SCRIPT_GetNumber(scripthandle, "Screen Setup", "Out",&ud.lockout); SCRIPT_GetNumber(scripthandle, "Screen Setup", "Out",&ud.lockout);
} }
@ -647,8 +690,12 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache); SCRIPT_GetNumber(scripthandle, "Screen Setup", "GLUseCompressedTextureCache", &glusetexcache);
SCRIPT_GetNumber(scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression); SCRIPT_GetNumber(scripthandle, "Screen Setup", "GLUseTextureCacheCompression", &glusetexcachecompression);
dummy = usemodels; SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseModels",&dummy); usemodels = dummy != 0; dummy = usemodels;
dummy = usehightile; SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseHightile",&dummy); usehightile = dummy != 0; SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseModels",&dummy);
usemodels = dummy != 0;
dummy = usehightile;
SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseHightile",&dummy);
usehightile = dummy != 0;
#endif #endif
SCRIPT_GetNumber(scripthandle, "Misc", "Executions",&ud.executions); SCRIPT_GetNumber(scripthandle, "Misc", "Executions",&ud.executions);
SCRIPT_GetNumber(scripthandle, "Setup", "ForceSetup",&ForceSetup); SCRIPT_GetNumber(scripthandle, "Setup", "ForceSetup",&ForceSetup);
@ -673,7 +720,9 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(scripthandle, "Misc", "AutoMsg",&ud.automsg); SCRIPT_GetNumber(scripthandle, "Misc", "AutoMsg",&ud.automsg);
SCRIPT_GetNumber(scripthandle, "Misc", "IDPlayers",&ud.automsg); SCRIPT_GetNumber(scripthandle, "Misc", "IDPlayers",&ud.automsg);
dummy = useprecache; SCRIPT_GetNumber(scripthandle, "Misc", "UsePrecache",&dummy); useprecache = dummy != 0; dummy = useprecache;
SCRIPT_GetNumber(scripthandle, "Misc", "UsePrecache",&dummy);
useprecache = dummy != 0;
// weapon choices are defaulted in checkcommandline, which may override them // weapon choices are defaulted in checkcommandline, which may override them
if (!CommandWeaponChoice) if (!CommandWeaponChoice)
@ -787,7 +836,8 @@ void CONFIG_WriteSetup(void)
#endif #endif
SCRIPT_PutNumber(scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false); SCRIPT_PutNumber(scripthandle, "Screen Setup", "Messages",ud.fta_on,false,false);
if (!NAM) { if (!NAM)
{
SCRIPT_PutNumber(scripthandle, "Screen Setup", "Out",ud.lockout,false,false); SCRIPT_PutNumber(scripthandle, "Screen Setup", "Out",ud.lockout,false,false);
SCRIPT_PutString(scripthandle, "Screen Setup", "Password",ud.pwlockout); SCRIPT_PutString(scripthandle, "Screen Setup", "Password",ud.pwlockout);
} }
@ -813,7 +863,8 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(scripthandle, "Sound Setup", "VoiceToggle",VoiceToggle,false,false); SCRIPT_PutNumber(scripthandle, "Sound Setup", "VoiceToggle",VoiceToggle,false,false);
// JBF 20031211 // JBF 20031211
for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++) { for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++)
{
SCRIPT_PutDoubleString(scripthandle, "KeyDefinitions", CONFIG_FunctionNumToName(dummy), SCRIPT_PutDoubleString(scripthandle, "KeyDefinitions", CONFIG_FunctionNumToName(dummy),
KB_ScanCodeToString(KeyboardKeys[dummy][0]), KB_ScanCodeToString(KeyboardKeys[dummy][1])); KB_ScanCodeToString(KeyboardKeys[dummy][0]), KB_ScanCodeToString(KeyboardKeys[dummy][1]));
} }
@ -824,7 +875,8 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(scripthandle, "Misc",buf,ud.wchoice[myconnectindex][dummy],false,false); SCRIPT_PutNumber(scripthandle, "Misc",buf,ud.wchoice[myconnectindex][dummy],false,false);
} }
for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++) { for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++)
{
Bsprintf(buf,"MouseButton%ld",dummy); Bsprintf(buf,"MouseButton%ld",dummy);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][0])); SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][0]));
@ -833,7 +885,8 @@ void CONFIG_WriteSetup(void)
Bsprintf(buf,"MouseButtonClicked%ld",dummy); Bsprintf(buf,"MouseButtonClicked%ld",dummy);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][1])); SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][1]));
} }
for (dummy=0;dummy<MAXMOUSEAXES;dummy++) { for (dummy=0;dummy<MAXMOUSEAXES;dummy++)
{
Bsprintf(buf,"MouseAnalogAxes%ld",dummy); Bsprintf(buf,"MouseAnalogAxes%ld",dummy);
SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[dummy])); SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[dummy]));
@ -849,14 +902,16 @@ void CONFIG_WriteSetup(void)
dummy = CONTROL_GetMouseSensitivity(); dummy = CONTROL_GetMouseSensitivity();
SCRIPT_PutNumber(scripthandle, "Controls","Mouse_Sensitivity",dummy,false,false); SCRIPT_PutNumber(scripthandle, "Controls","Mouse_Sensitivity",dummy,false,false);
for (dummy=0;dummy<MAXJOYBUTTONS;dummy++) { for (dummy=0;dummy<MAXJOYBUTTONS;dummy++)
{
Bsprintf(buf,"JoystickButton%ld",dummy); Bsprintf(buf,"JoystickButton%ld",dummy);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][0])); SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][0]));
Bsprintf(buf,"JoystickButtonClicked%ld",dummy); Bsprintf(buf,"JoystickButtonClicked%ld",dummy);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][1])); SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][1]));
} }
for (dummy=0;dummy<MAXJOYAXES;dummy++) { for (dummy=0;dummy<MAXJOYAXES;dummy++)
{
Bsprintf(buf,"JoystickAnalogAxes%ld",dummy); Bsprintf(buf,"JoystickAnalogAxes%ld",dummy);
SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy])); SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy]));

File diff suppressed because it is too large Load diff

View file

@ -87,7 +87,8 @@ void FreeGameVars(void);
extern long qsetmode; extern long qsetmode;
enum errors { enum errors
{
ERROR_CLOSEBRACKET, ERROR_CLOSEBRACKET,
ERROR_EVENTONLY, ERROR_EVENTONLY,
ERROR_EXCEEDSMAXTILES, ERROR_EXCEEDSMAXTILES,
@ -108,7 +109,8 @@ enum errors {
WARNING_LABELSONLY, WARNING_LABELSONLY,
}; };
enum labeltypes { enum labeltypes
{
LABEL_ANY = -1, LABEL_ANY = -1,
LABEL_DEFINE = 1, LABEL_DEFINE = 1,
LABEL_STATE = 2, LABEL_STATE = 2,
@ -118,7 +120,8 @@ enum labeltypes {
LABEL_MOVE = 32, LABEL_MOVE = 32,
}; };
static char *labeltypenames[] = { static char *labeltypenames[] =
{
"define", "define",
"state", "state",
"actor", "actor",
@ -133,7 +136,8 @@ static char *translatelabeltype(long type)
char x[64]; char x[64];
x[0] = 0; x[0] = 0;
for (i=0;i<6;i++) { for (i=0;i<6;i++)
{
if (!(type & (1<<i))) continue; if (!(type & (1<<i))) continue;
if (x[0]) Bstrcat(x, " or "); if (x[0]) Bstrcat(x, " or ");
Bstrcat(x, labeltypenames[i]); Bstrcat(x, labeltypenames[i]);
@ -860,7 +864,8 @@ void skipcomments(void)
{ {
if (c == ' ' || c == '\t' || c == '\r') if (c == ' ' || c == '\t' || c == '\r')
textptr++; textptr++;
else if (c == '\n') { else if (c == '\n')
{
line_number++; line_number++;
textptr++; textptr++;
} }
@ -1965,7 +1970,8 @@ char parsecommand(void)
long tw; long tw;
if (((unsigned)(scriptptr-script) > MAXSCRIPTSIZE) && error == 0) { if (((unsigned)(scriptptr-script) > MAXSCRIPTSIZE) && error == 0)
{
/* Bsprintf(tempbuf,"fatal error: Size of compiled CON code exceeds maximum size! (%ud, %d)\n",(unsigned)(scriptptr-script),MAXSCRIPTSIZE); */ /* Bsprintf(tempbuf,"fatal error: Size of compiled CON code exceeds maximum size! (%ud, %d)\n",(unsigned)(scriptptr-script),MAXSCRIPTSIZE); */
ReportError(-1); ReportError(-1);
initprintf("%s:%ld: internal compiler error: Aborted (%ud)\n",compilefile,line_number,(unsigned)(scriptptr-script)); initprintf("%s:%ld: internal compiler error: Aborted (%ud)\n",compilefile,line_number,(unsigned)(scriptptr-script));
@ -2462,7 +2468,8 @@ char parsecommand(void)
checking_ifelse = 0; checking_ifelse = 0;
textptr = mptr; textptr = mptr;
do done = parsecommand(); while (!done); do done = parsecommand();
while (!done);
Bstrcpy(compilefile, parentcompilefile); Bstrcpy(compilefile, parentcompilefile);
total_lines += line_number; total_lines += line_number;
@ -2640,9 +2647,11 @@ char parsecommand(void)
switch (j) switch (j)
{ {
case 0: case 0:
transnum(LABEL_DEFINE); break; transnum(LABEL_DEFINE);
break;
case 1: case 1:
transnum(LABEL_ACTION); break; transnum(LABEL_ACTION);
break;
case 2: case 2:
if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1))
{ {
@ -2796,9 +2805,11 @@ char parsecommand(void)
switch (j) switch (j)
{ {
case 0: case 0:
transnum(LABEL_DEFINE); break; transnum(LABEL_DEFINE);
break;
case 1: case 1:
transnum(LABEL_ACTION); break; transnum(LABEL_ACTION);
break;
case 2: case 2:
if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)) if ((transnum(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1))
{ {
@ -3893,7 +3904,8 @@ char parsecommand(void)
if (!CheckEventSync(current_event)) if (!CheckEventSync(current_event))
ReportError(WARNING_EVENTSYNC); ReportError(WARNING_EVENTSYNC);
transmultvars(4); transmultvars(4);
if (tw == CON_MOVESPRITE) { if (tw == CON_MOVESPRITE)
{
transvar(); transvar();
transvartype(GAMEVAR_FLAG_READONLY); transvartype(GAMEVAR_FLAG_READONLY);
} }
@ -4797,10 +4809,13 @@ repeatcase:
if (j != 25) continue; if (j != 25) continue;
if (keyword() != -1) { if (keyword() != -1)
{
initprintf("Duke Nukem 3D v1.3D style CON files detected.\n"); initprintf("Duke Nukem 3D v1.3D style CON files detected.\n");
break; break;
} else { }
else
{
conversion = 14; conversion = 14;
initprintf("Duke Nukem 3D v1.4+ style CON files detected.\n"); initprintf("Duke Nukem 3D v1.4+ style CON files detected.\n");
} }
@ -4870,7 +4885,8 @@ repeatcase:
camerashitable = params[j++]; camerashitable = params[j++];
numfreezebounces = params[j++]; numfreezebounces = params[j++];
freezerhurtowner = params[j++]; freezerhurtowner = params[j++];
if (conversion == 14) { if (conversion == 14)
{
spriteqamount = params[j++]; spriteqamount = params[j++];
if (spriteqamount > 1024) spriteqamount = 1024; if (spriteqamount > 1024) spriteqamount = 1024;
else if (spriteqamount < 0) spriteqamount = 0; else if (spriteqamount < 0) spriteqamount = 0;
@ -4924,7 +4940,8 @@ void copydefaultcons(void)
fpo = fopenfrompath(defaultcons[i],"wb"); fpo = fopenfrompath(defaultcons[i],"wb");
if (fpo == NULL) { if (fpo == NULL)
{
kclose(fpi); kclose(fpi);
continue; continue;
} }
@ -5661,7 +5678,8 @@ void AddDefaultDefinitions(void)
void InitProjectiles(void) void InitProjectiles(void)
{ {
int i; int i;
for (i=0;i<MAXTILES;i++) { for (i=0;i<MAXTILES;i++)
{
projectile[i].workslike = 1; projectile[i].workslike = 1;
projectile[i].spawns = SMALLSMOKE; projectile[i].spawns = SMALLSMOKE;
projectile[i].sxrepeat = projectile[i].syrepeat = -1; projectile[i].sxrepeat = projectile[i].syrepeat = -1;
@ -5805,7 +5823,8 @@ void loadefs(char *filenam)
{ {
if (loadfromgrouponly == 1) if (loadfromgrouponly == 1)
gameexit("Missing CON file(s); replace duke3d.grp with a known good copy."); gameexit("Missing CON file(s); replace duke3d.grp with a known good copy.");
else { else
{
Bsprintf(tempbuf,"CON file `%s' missing.", filenam); Bsprintf(tempbuf,"CON file `%s' missing.", filenam);
gameexit(tempbuf); gameexit(tempbuf);
return; return;
@ -5820,7 +5839,8 @@ void loadefs(char *filenam)
initprintf("Compiling: %s (%ld bytes)\n",filenam,fs); initprintf("Compiling: %s (%ld bytes)\n",filenam,fs);
mptr = (char *)Bmalloc(fs+1); mptr = (char *)Bmalloc(fs+1);
if (!mptr) { if (!mptr)
{
Bsprintf(tempbuf,"Failed allocating %ld byte CON text buffer.", fs+1); Bsprintf(tempbuf,"Failed allocating %ld byte CON text buffer.", fs+1);
gameexit(tempbuf); gameexit(tempbuf);
} }

View file

@ -3088,7 +3088,8 @@ char dodge(spritetype *s)
mx = s->x; mx = s->x;
my = s->y; my = s->y;
mxvect = sintable[(s->ang+512)&2047]; myvect = sintable[s->ang&2047]; mxvect = sintable[(s->ang+512)&2047];
myvect = sintable[s->ang&2047];
for (i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list for (i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list
{ {
@ -3097,7 +3098,8 @@ char dodge(spritetype *s)
bx = SX-mx; bx = SX-mx;
by = SY-my; by = SY-my;
bxvect = sintable[(SA+512)&2047]; byvect = sintable[SA&2047]; bxvect = sintable[(SA+512)&2047];
byvect = sintable[SA&2047];
if (mxvect*bx + myvect*by >= 0) if (mxvect*bx + myvect*by >= 0)
if (bxvect*bx + byvect*by < 0) if (bxvect*bx + byvect*by < 0)
@ -3652,14 +3654,18 @@ char parse(void)
j = 0; j = 0;
else else
{ {
g_sp->ang += angdif;j = hitasprite(g_i,&temphit);g_sp->ang -= angdif; g_sp->ang += angdif;
j = hitasprite(g_i,&temphit);
g_sp->ang -= angdif;
if (j > sclip) if (j > sclip)
{ {
if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum)
j = 0; j = 0;
else else
{ {
g_sp->ang -= angdif;j = hitasprite(g_i,&temphit);g_sp->ang += angdif; g_sp->ang -= angdif;
j = hitasprite(g_i,&temphit);
g_sp->ang += angdif;
if (j > 768) if (j > 768)
{ {
if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum) if (temphit >= 0 && sprite[temphit].picnum == g_sp->picnum)
@ -4035,7 +4041,8 @@ SKIPJIBS:
} }
addammo(*insptr, &ps[g_p], *(insptr+1)); addammo(*insptr, &ps[g_p], *(insptr+1));
if (ps[g_p].curr_weapon == KNEE_WEAPON) if (ps[g_p].curr_weapon == KNEE_WEAPON)
if (ps[g_p].gotweapon[*insptr]) { if (ps[g_p].gotweapon[*insptr])
{
if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr);
else addweapon(&ps[g_p], *insptr); else addweapon(&ps[g_p], *insptr);
} }
@ -4080,7 +4087,8 @@ SKIPJIBS:
case CON_ADDWEAPON: case CON_ADDWEAPON:
insptr++; insptr++;
if (ps[g_p].gotweapon[*insptr] == 0) { if (ps[g_p].gotweapon[*insptr] == 0)
{
if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr);
else addweapon(&ps[g_p], *insptr); else addweapon(&ps[g_p], *insptr);
} }
@ -4091,7 +4099,8 @@ SKIPJIBS:
} }
addammo(*insptr, &ps[g_p], *(insptr+1)); addammo(*insptr, &ps[g_p], *(insptr+1));
if (ps[g_p].curr_weapon == KNEE_WEAPON) if (ps[g_p].curr_weapon == KNEE_WEAPON)
if (ps[g_p].gotweapon[*insptr]) { if (ps[g_p].gotweapon[*insptr])
{
if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr); if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], *insptr);
else addweapon(&ps[g_p], *insptr); else addweapon(&ps[g_p], *insptr);
} }
@ -4204,7 +4213,8 @@ SKIPJIBS:
case CON_ADDWEAPONVAR: case CON_ADDWEAPONVAR:
insptr++; insptr++;
if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0) { if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)] == 0)
{
if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p));
else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p));
} }
@ -4215,7 +4225,8 @@ SKIPJIBS:
} }
addammo(GetGameVarID(*(insptr),g_i,g_p), &ps[g_p], GetGameVarID(*(insptr+1),g_i,g_p)); addammo(GetGameVarID(*(insptr),g_i,g_p), &ps[g_p], GetGameVarID(*(insptr+1),g_i,g_p));
if (ps[g_p].curr_weapon == KNEE_WEAPON) if (ps[g_p].curr_weapon == KNEE_WEAPON)
if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)]) { if (ps[g_p].gotweapon[GetGameVarID(*(insptr),g_i,g_p)])
{
if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); if (!(ps[g_p].weaponswitch & 1)) addweaponnoswitch(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p));
else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p)); else addweapon(&ps[g_p], GetGameVarID(*(insptr),g_i,g_p));
} }
@ -4237,7 +4248,8 @@ SKIPJIBS:
{ {
var2 = g_p; var2 = g_p;
insptr++; insptr++;
} else var2 = GetGameVarID(*insptr++,g_i,g_p); }
else var2 = GetGameVarID(*insptr++,g_i,g_p);
switch (tw) switch (tw)
{ {
@ -4330,7 +4342,8 @@ SKIPJIBS:
{ {
j = g_p; j = g_p;
insptr++; insptr++;
} else j = GetGameVarID(*insptr++, g_i, g_p); }
else j = GetGameVarID(*insptr++, g_i, g_p);
switch (tw) switch (tw)
{ {
@ -4340,7 +4353,8 @@ SKIPJIBS:
if (ud.user_name[j][0]) if (ud.user_name[j][0])
Bstrcpy(fta_quotes[i],ud.user_name[j]); Bstrcpy(fta_quotes[i],ud.user_name[j]);
else Bsprintf(fta_quotes[i],"%d",j); else Bsprintf(fta_quotes[i],"%d",j);
} else OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,i); }
else OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,i);
break; break;
case CON_QSTRCAT: case CON_QSTRCAT:
if (fta_quotes[i] != NULL && fta_quotes[j] != NULL) if (fta_quotes[i] != NULL && fta_quotes[j] != NULL)
@ -4420,7 +4434,11 @@ SKIPJIBS:
if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
} }
} }
else { ps[myconnectindex].gm |= MODE_EOL; display_bonus_screen = 0; } // MODE_RESTART; else
{
ps[myconnectindex].gm |= MODE_EOL;
display_bonus_screen = 0;
} // MODE_RESTART;
break; break;
} }
@ -4663,7 +4681,8 @@ SKIPJIBS:
lIn=GetGameVarID(lIn, g_i, g_p); lIn=GetGameVarID(lIn, g_i, g_p);
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i, lIn); lReturn = spawn(g_i, lIn);
switch (tw) { switch (tw)
{
case CON_EQSPAWNVAR: case CON_EQSPAWNVAR:
insertspriteq(lReturn); insertspriteq(lReturn);
case CON_ESPAWNVAR: case CON_ESPAWNVAR:
@ -4685,7 +4704,8 @@ SKIPJIBS:
insptr++; insptr++;
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
lReturn = spawn(g_i,*insptr++); lReturn = spawn(g_i,*insptr++);
switch (tw) { switch (tw)
{
case CON_EQSPAWN: case CON_EQSPAWN:
insertspriteq(lReturn); insertspriteq(lReturn);
case CON_ESPAWN: case CON_ESPAWN:
@ -5333,11 +5353,14 @@ SKIPJIBS:
switch (g_sp->pal) switch (g_sp->pal)
{ {
case 0: case 0:
ps[g_p].got_access |= 1;break; ps[g_p].got_access |= 1;
break;
case 21: case 21:
ps[g_p].got_access |= 2;break; ps[g_p].got_access |= 2;
break;
case 23: case 23:
ps[g_p].got_access |= 4;break; ps[g_p].got_access |= 4;
break;
} }
break; break;
@ -5556,7 +5579,9 @@ SKIPJIBS:
var3 = GetGameVarID(*insptr++, g_i, g_p); var3 = GetGameVarID(*insptr++, g_i, g_p);
var4 = GetGameVarID(*insptr++, g_i, g_p); var4 = GetGameVarID(*insptr++, g_i, g_p);
Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4); Bsprintf(fta_quotes[dq],tempbuf,var1,var2,var3,var4);
} else { }
else
{
if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq); if (fta_quotes[sq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,sq);
if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq); if (fta_quotes[dq] == NULL) OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,dq);
insptr += 5; insptr += 5;
@ -6691,28 +6716,37 @@ good:
j = 1; j = 1;
break; break;
case GET_SCUBA: case GET_SCUBA:
if (ps[g_p].scuba_amount != *insptr) j = 1;break; if (ps[g_p].scuba_amount != *insptr) j = 1;
break;
case GET_HOLODUKE: case GET_HOLODUKE:
if (ps[g_p].holoduke_amount != *insptr) j = 1;break; if (ps[g_p].holoduke_amount != *insptr) j = 1;
break;
case GET_JETPACK: case GET_JETPACK:
if (ps[g_p].jetpack_amount != *insptr) j = 1;break; if (ps[g_p].jetpack_amount != *insptr) j = 1;
break;
case GET_ACCESS: case GET_ACCESS:
switch (g_sp->pal) switch (g_sp->pal)
{ {
case 0: case 0:
if (ps[g_p].got_access&1) j = 1;break; if (ps[g_p].got_access&1) j = 1;
break;
case 21: case 21:
if (ps[g_p].got_access&2) j = 1;break; if (ps[g_p].got_access&2) j = 1;
break;
case 23: case 23:
if (ps[g_p].got_access&4) j = 1;break; if (ps[g_p].got_access&4) j = 1;
break;
} }
break; break;
case GET_HEATS: case GET_HEATS:
if (ps[g_p].heat_amount != *insptr) j = 1;break; if (ps[g_p].heat_amount != *insptr) j = 1;
break;
case GET_FIRSTAID: case GET_FIRSTAID:
if (ps[g_p].firstaid_amount != *insptr) j = 1;break; if (ps[g_p].firstaid_amount != *insptr) j = 1;
break;
case GET_BOOTS: case GET_BOOTS:
if (ps[g_p].boot_amount != *insptr) j = 1;break; if (ps[g_p].boot_amount != *insptr) j = 1;
break;
} }
parseifelse(j); parseifelse(j);
@ -6771,7 +6805,8 @@ good:
insptr++; insptr++;
if (fta_quotes[*insptr] != NULL) if (fta_quotes[*insptr] != NULL)
FTA(*insptr++,&ps[g_p]); FTA(*insptr++,&ps[g_p]);
else { else
{
OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr);
insptr++; insptr++;
} }
@ -6781,7 +6816,8 @@ good:
insptr++; insptr++;
if (fta_quotes[*insptr] != NULL) if (fta_quotes[*insptr] != NULL)
adduserquote(fta_quotes[*insptr++]); adduserquote(fta_quotes[*insptr++]);
else { else
{
OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr); OSD_Printf("%s %d null quote %d\n",__FILE__,__LINE__,*insptr);
insptr++; insptr++;
} }

View file

@ -8,8 +8,10 @@
#include "duke3d.h" #include "duke3d.h"
#include "grpscan.h" #include "grpscan.h"
struct grpfile grpfiles[numgrpfiles] = { struct grpfile grpfiles[numgrpfiles] =
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL } {
{ "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL
}
, ,
{ "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL },
{ "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL },
@ -21,13 +23,15 @@ struct grpfile grpfiles[numgrpfiles] = {
struct grpfile *foundgrps = NULL; struct grpfile *foundgrps = NULL;
#define GRPCACHEFILE "grpfiles.cache" #define GRPCACHEFILE "grpfiles.cache"
static struct grpcache { static struct grpcache
{
struct grpcache *next; struct grpcache *next;
char name[BMAX_PATH+1]; char name[BMAX_PATH+1];
int size; int size;
int mtime; int mtime;
int crcval; int crcval;
} *grpcache = NULL, *usedgrpcache = NULL; }
*grpcache = NULL, *usedgrpcache = NULL;
static int LoadGroupsCache(void) static int LoadGroupsCache(void)
{ {
@ -41,7 +45,8 @@ static int LoadGroupsCache(void)
script = scriptfile_fromfile(GRPCACHEFILE); script = scriptfile_fromfile(GRPCACHEFILE);
if (!script) return -1; if (!script) return -1;
while (!scriptfile_eof(script)) { while (!scriptfile_eof(script))
{
if (scriptfile_getstring(script, &fname)) break; // filename if (scriptfile_getstring(script, &fname)) break; // filename
if (scriptfile_getnumber(script, &fsize)) break; // filesize if (scriptfile_getnumber(script, &fsize)) break; // filesize
if (scriptfile_getnumber(script, &fmtime)) break; // modification time if (scriptfile_getnumber(script, &fmtime)) break; // modification time
@ -65,7 +70,8 @@ static void FreeGroupsCache(void)
{ {
struct grpcache *fg; struct grpcache *fg;
while (grpcache) { while (grpcache)
{
fg = grpcache->next; fg = grpcache->next;
free(grpcache); free(grpcache);
grpcache = fg; grpcache = fg;
@ -86,16 +92,24 @@ int ScanGroups(void)
srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE); srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);
for (sidx = srch; sidx; sidx = sidx->next) { for (sidx = srch; sidx; sidx = sidx->next)
for (fg = grpcache; fg; fg = fg->next) { {
for (fg = grpcache; fg; fg = fg->next)
{
if (!Bstrcmp(fg->name, sidx->name)) break; if (!Bstrcmp(fg->name, sidx->name)) break;
} }
if (fg) { if (fg)
{
if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename if (findfrompath(sidx->name, &fn)) continue; // failed to resolve the filename
if (Bstat(fn, &st)) { free(fn); continue; } // failed to stat the file if (Bstat(fn, &st))
{
free(fn); free(fn);
if (fg->size == st.st_size && fg->mtime == st.st_mtime) { continue;
} // failed to stat the file
free(fn);
if (fg->size == st.st_size && fg->mtime == st.st_mtime)
{
grp = (struct grpfile *)calloc(1, sizeof(struct grpfile)); grp = (struct grpfile *)calloc(1, sizeof(struct grpfile));
grp->name = strdup(sidx->name); grp->name = strdup(sidx->name);
grp->crcval = fg->crcval; grp->crcval = fg->crcval;
@ -125,10 +139,12 @@ int ScanGroups(void)
initprintf(" Checksumming %s...", sidx->name); initprintf(" Checksumming %s...", sidx->name);
crc32init((unsigned long *)&crcval); crc32init((unsigned long *)&crcval);
do { do
{
b = read(fh, buf, sizeof(buf)); b = read(fh, buf, sizeof(buf));
if (b > 0) crc32block((unsigned long *)&crcval, buf, b); if (b > 0) crc32block((unsigned long *)&crcval, buf, b);
} while (b == sizeof(buf)); }
while (b == sizeof(buf));
crc32finish((unsigned long *)&crcval); crc32finish((unsigned long *)&crcval);
close(fh); close(fh);
initprintf(" Done\n"); initprintf(" Done\n");
@ -153,11 +169,14 @@ int ScanGroups(void)
klistfree(srch); klistfree(srch);
FreeGroupsCache(); FreeGroupsCache();
if (usedgrpcache) { if (usedgrpcache)
{
FILE *fp; FILE *fp;
fp = fopen(GRPCACHEFILE, "wt"); fp = fopen(GRPCACHEFILE, "wt");
if (fp) { if (fp)
for (fg = usedgrpcache; fg; fg=fgg) { {
for (fg = usedgrpcache; fg; fg=fgg)
{
fgg = fg->next; fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval); fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
free(fg); free(fg);
@ -173,7 +192,8 @@ void FreeGroups(void)
{ {
struct grpfile *fg; struct grpfile *fg;
while (foundgrps) { while (foundgrps)
{
fg = foundgrps->next; fg = foundgrps->next;
free((char*)foundgrps->name); free((char*)foundgrps->name);
free(foundgrps); free(foundgrps);

File diff suppressed because it is too large Load diff

View file

@ -768,7 +768,8 @@ unsigned short dynamictostatic[MAXTILES];
void processnames(char *szLabel, long lValue) void processnames(char *szLabel, long lValue)
{ {
switch (szLabel[0]) { switch (szLabel[0])
{
case 'A': case 'A':
if (!Bstrcmp(szLabel,"ACTIVATOR")) ACTIVATOR = lValue; if (!Bstrcmp(szLabel,"ACTIVATOR")) ACTIVATOR = lValue;
else if (!Bstrcmp(szLabel,"ACTIVATORLOCKED")) ACTIVATORLOCKED = lValue; else if (!Bstrcmp(szLabel,"ACTIVATORLOCKED")) ACTIVATORLOCKED = lValue;

View file

@ -36,7 +36,8 @@ int osdcmd_quit(const osdfuncparm_t *parm)
int osdcmd_echo(const osdfuncparm_t *parm) int osdcmd_echo(const osdfuncparm_t *parm)
{ {
int i; int i;
for (i = 0; i < parm->numparms; i++) { for (i = 0; i < parm->numparms; i++)
{
if (i > 0) OSD_Printf(" "); if (i > 0) OSD_Printf(" ");
OSD_Printf("%s", parm->parms[i]); OSD_Printf("%s", parm->parms[i]);
} }
@ -50,14 +51,17 @@ int osdcmd_changelevel(const osdfuncparm_t *parm)
int volume=0,level; int volume=0,level;
char *p; char *p;
if (!VOLUMEONE) { if (!VOLUMEONE)
{
if (parm->numparms != 2) return OSDCMD_SHOWHELP; if (parm->numparms != 2) return OSDCMD_SHOWHELP;
volume = strtol(parm->parms[0], &p, 10) - 1; volume = strtol(parm->parms[0], &p, 10) - 1;
if (p[0]) return OSDCMD_SHOWHELP; if (p[0]) return OSDCMD_SHOWHELP;
level = strtol(parm->parms[1], &p, 10) - 1; level = strtol(parm->parms[1], &p, 10) - 1;
if (p[0]) return OSDCMD_SHOWHELP; if (p[0]) return OSDCMD_SHOWHELP;
} else { }
else
{
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
level = strtol(parm->parms[0], &p, 10) - 1; level = strtol(parm->parms[0], &p, 10) - 1;
@ -67,31 +71,41 @@ int osdcmd_changelevel(const osdfuncparm_t *parm)
if (volume < 0) return OSDCMD_SHOWHELP; if (volume < 0) return OSDCMD_SHOWHELP;
if (level < 0) return OSDCMD_SHOWHELP; if (level < 0) return OSDCMD_SHOWHELP;
if (!VOLUMEONE) { if (!VOLUMEONE)
if (volume > num_volumes) { {
if (volume > num_volumes)
{
OSD_Printf("changelevel: invalid volume number (range 1-%ld)\n",num_volumes); OSD_Printf("changelevel: invalid volume number (range 1-%ld)\n",num_volumes);
return OSDCMD_OK; return OSDCMD_OK;
} }
} }
if (volume == 0) { if (volume == 0)
if (level > 6) { {
if (level > 6)
{
OSD_Printf("changelevel: invalid volume 1 level number (range 1-7)\n"); OSD_Printf("changelevel: invalid volume 1 level number (range 1-7)\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
} else { }
if (level > 10) { else
{
if (level > 10)
{
OSD_Printf("changelevel: invalid volume 2+ level number (range 1-11)\n"); OSD_Printf("changelevel: invalid volume 2+ level number (range 1-11)\n");
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} }
} }
if (ps[myconnectindex].gm & MODE_GAME) { if (ps[myconnectindex].gm & MODE_GAME)
{
// in-game behave like a cheat // in-game behave like a cheat
osdcmd_cheatsinfo_stat.cheatnum = 2; osdcmd_cheatsinfo_stat.cheatnum = 2;
osdcmd_cheatsinfo_stat.volume = volume; osdcmd_cheatsinfo_stat.volume = volume;
osdcmd_cheatsinfo_stat.level = level; osdcmd_cheatsinfo_stat.level = level;
} else { }
else
{
// out-of-game behave like a menu command // out-of-game behave like a menu command
osdcmd_cheatsinfo_stat.cheatnum = -1; osdcmd_cheatsinfo_stat.cheatnum = -1;
@ -123,7 +137,8 @@ int osdcmd_map(const osdfuncparm_t *parm)
if (strchr(filename,'.') == 0) if (strchr(filename,'.') == 0)
strcat(filename,".map"); strcat(filename,".map");
if ((i = kopen4load(filename,0)) < 0) { if ((i = kopen4load(filename,0)) < 0)
{
OSD_Printf("map: file \"%s\" not found.\n", filename); OSD_Printf("map: file \"%s\" not found.\n", filename);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -131,12 +146,15 @@ int osdcmd_map(const osdfuncparm_t *parm)
strcpy(boardfilename, filename); strcpy(boardfilename, filename);
if (ps[myconnectindex].gm & MODE_GAME) { if (ps[myconnectindex].gm & MODE_GAME)
{
// in-game behave like a cheat // in-game behave like a cheat
osdcmd_cheatsinfo_stat.cheatnum = 2; osdcmd_cheatsinfo_stat.cheatnum = 2;
osdcmd_cheatsinfo_stat.volume = 0; osdcmd_cheatsinfo_stat.volume = 0;
osdcmd_cheatsinfo_stat.level = 7; osdcmd_cheatsinfo_stat.level = 7;
} else { }
else
{
// out-of-game behave like a menu command // out-of-game behave like a menu command
osdcmd_cheatsinfo_stat.cheatnum = -1; osdcmd_cheatsinfo_stat.cheatnum = -1;
@ -159,9 +177,12 @@ int osdcmd_map(const osdfuncparm_t *parm)
int osdcmd_god(const osdfuncparm_t *parm) int osdcmd_god(const osdfuncparm_t *parm)
{ {
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
osdcmd_cheatsinfo_stat.cheatnum = 0; osdcmd_cheatsinfo_stat.cheatnum = 0;
} else { }
else
{
OSD_Printf("god: Not in a single-player game.\n"); OSD_Printf("god: Not in a single-player game.\n");
} }
@ -170,9 +191,12 @@ int osdcmd_god(const osdfuncparm_t *parm)
int osdcmd_noclip(const osdfuncparm_t *parm) int osdcmd_noclip(const osdfuncparm_t *parm)
{ {
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
osdcmd_cheatsinfo_stat.cheatnum = 20; osdcmd_cheatsinfo_stat.cheatnum = 20;
} else { }
else
{
OSD_Printf("noclip: Not in a single-player game.\n"); OSD_Printf("noclip: Not in a single-player game.\n");
} }
@ -187,7 +211,8 @@ int osdcmd_fileinfo(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if ((i = kopen4load((char *)parm->parms[0],0)) < 0) { if ((i = kopen4load((char *)parm->parms[0],0)) < 0)
{
OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]); OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -195,10 +220,12 @@ int osdcmd_fileinfo(const osdfuncparm_t *parm)
length = kfilelength(i); length = kfilelength(i);
crc32init(&crc); crc32init(&crc);
do { do
{
j = kread(i,buf,256); j = kread(i,buf,256);
crc32block(&crc,buf,j); crc32block(&crc,buf,j);
} while (j == 256); }
while (j == 256);
crc32finish(&crc); crc32finish(&crc);
kclose(i); kclose(i);
@ -228,7 +255,8 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
newheight = ScreenHeight, newfs = ScreenMode; newheight = ScreenHeight, newfs = ScreenMode;
if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP; if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
switch (parm->numparms) { switch (parm->numparms)
{
case 1: // bpp switch case 1: // bpp switch
newbpp = Batol(parm->parms[0]); newbpp = Batol(parm->parms[0]);
break; break;
@ -246,12 +274,15 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
break; break;
} }
if (setgamemode(newfs,newwidth,newheight,newbpp)) { if (setgamemode(newfs,newwidth,newheight,newbpp))
{
initprintf("vidmode: Mode change failed!\n"); initprintf("vidmode: Mode change failed!\n");
if (setgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP)) if (setgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP))
gameexit("vidmode: Reset failed!\n"); gameexit("vidmode: Reset failed!\n");
} }
ScreenBPP = newbpp; ScreenWidth = newwidth; ScreenHeight = newheight; ScreenBPP = newbpp;
ScreenWidth = newwidth;
ScreenHeight = newheight;
ScreenMode = newfs; ScreenMode = newfs;
onvideomodechange(ScreenBPP>8); onvideomodechange(ScreenBPP>8);
vscrn(); vscrn();
@ -260,10 +291,12 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm) static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
{ {
if (parm->numparms == 0) { if (parm->numparms == 0)
{
OSD_Printf("\"cl_statusbarscale\" is \"%d\"\n", ud.statusbarscale); OSD_Printf("\"cl_statusbarscale\" is \"%d\"\n", ud.statusbarscale);
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} else if (parm->numparms != 1) return OSDCMD_SHOWHELP; }
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
setstatusbarscale(Batol(parm->parms[0])); setstatusbarscale(Batol(parm->parms[0]));
OSD_Printf("cl_statusbarscale %d\n", ud.statusbarscale); OSD_Printf("cl_statusbarscale %d\n", ud.statusbarscale);
@ -272,10 +305,12 @@ static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
static int osdcmd_setstatusbarmode(const osdfuncparm_t *parm) static int osdcmd_setstatusbarmode(const osdfuncparm_t *parm)
{ {
if (parm->numparms == 0) { if (parm->numparms == 0)
{
OSD_Printf("\"cl_statusbarmode\" is \"%d\"\n", ud.statusbarmode); OSD_Printf("\"cl_statusbarmode\" is \"%d\"\n", ud.statusbarmode);
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} else if (parm->numparms != 1) return OSDCMD_SHOWHELP; }
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
ud.statusbarmode = Batol(parm->parms[0]); ud.statusbarmode = Batol(parm->parms[0]);
vscrn(); vscrn();
@ -291,47 +326,60 @@ static int osdcmd_spawn(const osdfuncparm_t *parm)
short ang=0; short ang=0;
short set=0, idx; short set=0, idx;
if (numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME)) { if (numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME))
{
OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n"); OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
switch (parm->numparms) { switch (parm->numparms)
{
case 7: // x,y,z case 7: // x,y,z
x = Batol(parm->parms[4]); x = Batol(parm->parms[4]);
y = Batol(parm->parms[5]); y = Batol(parm->parms[5]);
z = Batol(parm->parms[6]); z = Batol(parm->parms[6]);
set |= 8; set |= 8;
case 4: // ang case 4: // ang
ang = Batol(parm->parms[3]) & 2047; set |= 4; ang = Batol(parm->parms[3]) & 2047;
set |= 4;
case 3: // cstat case 3: // cstat
cstat = (unsigned short)Batol(parm->parms[2]); set |= 2; cstat = (unsigned short)Batol(parm->parms[2]);
set |= 2;
case 2: // pal case 2: // pal
pal = (unsigned char)Batol(parm->parms[1]); set |= 1; pal = (unsigned char)Batol(parm->parms[1]);
set |= 1;
case 1: // tile number case 1: // tile number
if (isdigit(parm->parms[0][0])) { if (isdigit(parm->parms[0][0]))
{
picnum = (unsigned short)Batol(parm->parms[0]); picnum = (unsigned short)Batol(parm->parms[0]);
} else { }
else
{
int i,j; int i,j;
for (j=0; j<2; j++) { for (j=0; j<2; j++)
for (i=0; i<labelcnt; i++) { {
for (i=0; i<labelcnt; i++)
{
if ( if (
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) || (j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0])) (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
) { )
{
picnum = (unsigned short)labelcode[i]; picnum = (unsigned short)labelcode[i];
break; break;
} }
} }
if (i<labelcnt) break; if (i<labelcnt) break;
} }
if (i==labelcnt) { if (i==labelcnt)
{
OSD_Printf("spawn: Invalid tile label given\n"); OSD_Printf("spawn: Invalid tile label given\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
} }
if (picnum >= MAXTILES) { if (picnum >= MAXTILES)
{
OSD_Printf("spawn: Invalid tile number\n"); OSD_Printf("spawn: Invalid tile number\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -344,8 +392,10 @@ static int osdcmd_spawn(const osdfuncparm_t *parm)
if (set & 1) sprite[idx].pal = (char)pal; if (set & 1) sprite[idx].pal = (char)pal;
if (set & 2) sprite[idx].cstat = (short)cstat; if (set & 2) sprite[idx].cstat = (short)cstat;
if (set & 4) sprite[idx].ang = ang; if (set & 4) sprite[idx].ang = ang;
if (set & 8) { if (set & 8)
if (setsprite(idx, x,y,z) < 0) { {
if (setsprite(idx, x,y,z) < 0)
{
OSD_Printf("spawn: Sprite can't be spawned into null space\n"); OSD_Printf("spawn: Sprite can't be spawned into null space\n");
deletesprite(idx); deletesprite(idx);
} }
@ -402,10 +452,13 @@ int osdcmd_initgroupfile(const osdfuncparm_t *parm)
int osdcmd_cmenu(const osdfuncparm_t *parm) int osdcmd_cmenu(const osdfuncparm_t *parm)
{ {
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if (numplayers > 1) { if (numplayers > 1)
{
OSD_Printf("cmenu: disallowed in multiplayer\n"); OSD_Printf("cmenu: disallowed in multiplayer\n");
return OSDCMD_OK; return OSDCMD_OK;
} else { }
else
{
cmenu(Batol(parm->parms[0])); cmenu(Batol(parm->parms[0]));
} }
@ -420,7 +473,8 @@ int osdcmd_exec(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
Bstrcpy(fn,parm->parms[0]); Bstrcpy(fn,parm->parms[0]);
if (load_script(fn)) { if (load_script(fn))
{
OSD_Printf("exec: file \"%s\" not found.\n", fn); OSD_Printf("exec: file \"%s\" not found.\n", fn);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -434,7 +488,8 @@ enum cvartypes {
CVAR_STRING CVAR_STRING
}; };
struct cvarmappings { struct cvarmappings
{
char *name; char *name;
char *helpstr; char *helpstr;
void *var; void *var;
@ -442,7 +497,8 @@ struct cvarmappings {
int extra; // for string, is the length int extra; // for string, is the length
int min; int min;
int max; int max;
} cvar[] = }
cvar[] =
{ {
{ "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_INT, 0, 0, 3 }, { "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_INT, 0, 0, 3 },
@ -466,8 +522,7 @@ struct cvarmappings {
{ "cl_weaponswitch", "cl_weaponswitch: enable/disable auto weapon switching", (void*)&ud.weaponswitch, CVAR_INT|256, 0, 0, 3 }, { "cl_weaponswitch", "cl_weaponswitch: enable/disable auto weapon switching", (void*)&ud.weaponswitch, CVAR_INT|256, 0, 0, 3 },
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
{ "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 } { "r_anamorphic", "r_anamorphic: enable/disable widescreen mode", (void*)&glwidescreen, CVAR_BOOL, 0, 0, 1 },
,
{ "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_BOOL, 0, 0, 1 }, { "r_projectionhack", "r_projectionhack: enable/disable projection hack", (void*)&glprojectionhacks, CVAR_BOOL, 0, 0, 1 },
// polymer cvars // polymer cvars
{ "pr_cliplanes", "pr_cliplanes: toggles clipping behind map limits (recommended yet may decrease performance in complex maps)", (void*)&pr_cliplanes, CVAR_INT, 0, 0, 1 }, { "pr_cliplanes", "pr_cliplanes: toggles clipping behind map limits (recommended yet may decrease performance in complex maps)", (void*)&pr_cliplanes, CVAR_INT, 0, 0, 1 },
@ -484,20 +539,26 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
int showval = (parm->numparms == 0); int showval = (parm->numparms == 0);
unsigned int i; unsigned int i;
for (i = 0; i < sizeof(cvar)/sizeof(struct cvarmappings); i++) { for (i = 0; i < sizeof(cvar)/sizeof(struct cvarmappings); i++)
if (!Bstrcasecmp(parm->name, cvar[i].name)) { {
if ((cvar[i].type & 0x80) && ud.multimode != 1) { if (!Bstrcasecmp(parm->name, cvar[i].name))
{
if ((cvar[i].type & 0x80) && ud.multimode != 1)
{
// sound the alarm // sound the alarm
OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name); OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} else }
switch (cvar[i].type&0x7f) { else
switch (cvar[i].type&0x7f)
{
case CVAR_INT: case CVAR_INT:
case CVAR_UNSIGNEDINT: case CVAR_UNSIGNEDINT:
case CVAR_BOOL: case CVAR_BOOL:
{ {
int val; int val;
if (showval) { if (showval)
{
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr); OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -505,25 +566,30 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
val = atoi(parm->parms[0]); val = atoi(parm->parms[0]);
if (cvar[i].type == CVAR_BOOL) val = val != 0; if (cvar[i].type == CVAR_BOOL) val = val != 0;
if (val < cvar[i].min || val > cvar[i].max) { if (val < cvar[i].min || val > cvar[i].max)
{
OSD_Printf("%s value out of range\n",cvar[i].name); OSD_Printf("%s value out of range\n",cvar[i].name);
return OSDCMD_OK; return OSDCMD_OK;
} }
*(int*)cvar[i].var = val; *(int*)cvar[i].var = val;
OSD_Printf("%s %d",cvar[i].name,val); OSD_Printf("%s %d",cvar[i].name,val);
} break; }
break;
case CVAR_STRING: case CVAR_STRING:
{ {
if (showval) { if (showval)
{
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr); OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
return OSDCMD_OK; return OSDCMD_OK;
} }
else { else
{
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1); Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
((char*)cvar[i].var)[cvar[i].extra-1] = 0; ((char*)cvar[i].var)[cvar[i].extra-1] = 0;
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var); OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
} }
} break; }
break;
default: default:
break; break;
} }
@ -537,7 +603,8 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
int osdcmd_sensitivity(const osdfuncparm_t *parm) int osdcmd_sensitivity(const osdfuncparm_t *parm)
{ {
if (parm->numparms != 1) { if (parm->numparms != 1)
{
OSD_Printf("\"sensitivity\" is \"%d\"\n",CONTROL_GetMouseSensitivity()); OSD_Printf("\"sensitivity\" is \"%d\"\n",CONTROL_GetMouseSensitivity());
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} }
@ -548,7 +615,8 @@ int osdcmd_sensitivity(const osdfuncparm_t *parm)
int osdcmd_gamma(const osdfuncparm_t *parm) int osdcmd_gamma(const osdfuncparm_t *parm)
{ {
if (parm->numparms != 1) { if (parm->numparms != 1)
{
OSD_Printf("\"gamma\" \"%d\"\n",ud.brightness>>2); OSD_Printf("\"gamma\" \"%d\"\n",ud.brightness>>2);
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} }
@ -562,44 +630,57 @@ int osdcmd_give(const osdfuncparm_t *parm)
{ {
int i; int i;
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) { if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
if (ps[myconnectindex].dead_flag != 0) { {
if (ps[myconnectindex].dead_flag != 0)
{
OSD_Printf("give: Cannot give while dead.\n"); OSD_Printf("give: Cannot give while dead.\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
if (parm->numparms != 1) return OSDCMD_SHOWHELP; if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if (!Bstrcasecmp(parm->parms[0], "all")) {
if (!Bstrcasecmp(parm->parms[0], "all"))
{
osdcmd_cheatsinfo_stat.cheatnum = 1; osdcmd_cheatsinfo_stat.cheatnum = 1;
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "health")) { else if (!Bstrcasecmp(parm->parms[0], "health"))
{
sprite[ps[myconnectindex].i].extra = 200; sprite[ps[myconnectindex].i].extra = 200;
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "weapons")) { else if (!Bstrcasecmp(parm->parms[0], "weapons"))
{
osdcmd_cheatsinfo_stat.cheatnum = 21; osdcmd_cheatsinfo_stat.cheatnum = 21;
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "ammo")) { else if (!Bstrcasecmp(parm->parms[0], "ammo"))
{
for (i=PISTOL_WEAPON;i<MAX_WEAPONS-(VOLUMEONE?6:1);i++) for (i=PISTOL_WEAPON;i<MAX_WEAPONS-(VOLUMEONE?6:1);i++)
{ {
addammo(i,&ps[myconnectindex],max_ammo_amount[i]); addammo(i,&ps[myconnectindex],max_ammo_amount[i]);
} }
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "armor")) { else if (!Bstrcasecmp(parm->parms[0], "armor"))
{
ps[myconnectindex].shield_amount = 100; ps[myconnectindex].shield_amount = 100;
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "keys")) { else if (!Bstrcasecmp(parm->parms[0], "keys"))
{
osdcmd_cheatsinfo_stat.cheatnum = 23; osdcmd_cheatsinfo_stat.cheatnum = 23;
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->parms[0], "inventory")) { else if (!Bstrcasecmp(parm->parms[0], "inventory"))
{
osdcmd_cheatsinfo_stat.cheatnum = 22; osdcmd_cheatsinfo_stat.cheatnum = 22;
return OSDCMD_OK; return OSDCMD_OK;
} }
} else { }
else
{
OSD_Printf("give: Not in a single-player game.\n"); OSD_Printf("give: Not in a single-player game.\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -610,14 +691,17 @@ void onvideomodechange(int newmode)
{ {
char *pal; char *pal;
if (newmode) { if (newmode)
{
if (ps[screenpeek].palette == palette || if (ps[screenpeek].palette == palette ||
ps[screenpeek].palette == waterpal || ps[screenpeek].palette == waterpal ||
ps[screenpeek].palette == slimepal) ps[screenpeek].palette == slimepal)
pal = palette; pal = palette;
else else
pal = ps[screenpeek].palette; pal = ps[screenpeek].palette;
} else { }
else
{
pal = ps[screenpeek].palette; pal = ps[screenpeek].palette;
} }
@ -628,17 +712,27 @@ void onvideomodechange(int newmode)
int osdcmd_usemousejoy(const osdfuncparm_t *parm) int osdcmd_usemousejoy(const osdfuncparm_t *parm)
{ {
int showval = (parm->numparms < 1); int showval = (parm->numparms < 1);
if (!Bstrcasecmp(parm->name, "usemouse")) { if (!Bstrcasecmp(parm->name, "usemouse"))
if (showval) { OSD_Printf("usemouse is %d\n", UseMouse); } {
else { if (showval)
{
OSD_Printf("usemouse is %d\n", UseMouse);
}
else
{
UseMouse = (atoi(parm->parms[0]) != 0); UseMouse = (atoi(parm->parms[0]) != 0);
CONTROL_MouseEnabled = (UseMouse && CONTROL_MousePresent); CONTROL_MouseEnabled = (UseMouse && CONTROL_MousePresent);
} }
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->name, "usejoystick")) { else if (!Bstrcasecmp(parm->name, "usejoystick"))
if (showval) { OSD_Printf("usejoystick is %d\n", UseJoystick); } {
else { if (showval)
{
OSD_Printf("usejoystick is %d\n", UseJoystick);
}
else
{
UseJoystick = (atoi(parm->parms[0]) != 0); UseJoystick = (atoi(parm->parms[0]) != 0);
CONTROL_JoystickEnabled = (UseJoystick && CONTROL_JoyPresent); CONTROL_JoystickEnabled = (UseJoystick && CONTROL_JoyPresent);
} }
@ -658,7 +752,8 @@ int osdcmd_mpmap(const osdfuncparm_t *parm)
if (strchr(filename,'.') == 0) if (strchr(filename,'.') == 0)
strcat(filename,".map"); strcat(filename,".map");
if ((i = kopen4load(filename,0)) < 0) { if ((i = kopen4load(filename,0)) < 0)
{
OSD_Printf("map: file \"%s\" not found.\n", filename); OSD_Printf("map: file \"%s\" not found.\n", filename);
return OSDCMD_OK; return OSDCMD_OK;
} }
@ -700,13 +795,17 @@ int registerosdcommands(void)
osdcmd_cheatsinfo_stat.cheatnum = -1; osdcmd_cheatsinfo_stat.cheatnum = -1;
for (i=0; i<sizeof(cvar)/sizeof(cvar[0]); i++) { for (i=0; i<sizeof(cvar)/sizeof(cvar[0]); i++)
{
OSD_RegisterFunction(cvar[i].name, cvar[i].helpstr, osdcmd_cvar_set); OSD_RegisterFunction(cvar[i].name, cvar[i].helpstr, osdcmd_cvar_set);
} }
if (VOLUMEONE) { if (VOLUMEONE)
{
OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel); OSD_RegisterFunction("changelevel","changelevel <level>: warps to the given level", osdcmd_changelevel);
} else { }
else
{
OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel); OSD_RegisterFunction("changelevel","changelevel <volume> <level>: warps to the given level", osdcmd_changelevel);
OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map); OSD_RegisterFunction("map","map <mapfile>: loads the given user map", osdcmd_map);
OSD_RegisterFunction("mpmap","mpmap <mapfile>: sets user map name in multiplayer", osdcmd_mpmap); OSD_RegisterFunction("mpmap","mpmap <mapfile>: sets user map name in multiplayer", osdcmd_mpmap);

View file

@ -17,8 +17,13 @@ void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal)
{ {
short ac; short ac;
for (x = (x<<3)+x; len>0; len--, ch++, x++) { for (x = (x<<3)+x; len>0; len--, ch++, x++)
if (*ch == 32) { x+=5; continue; } {
if (*ch == 32)
{
x+=5;
continue;
}
ac = *ch-'!'+STARTALPHANUM; ac = *ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) return; if (ac < STARTALPHANUM || ac > ENDALPHANUM) return;
@ -70,18 +75,22 @@ void GAME_clearbackground(int c, int r)
long x, y, xsiz, ysiz, tx2, ty2; long x, y, xsiz, ysiz, tx2, ty2;
long daydim, bits; long daydim, bits;
if (getrendermode() < 3) bits = BITS; else bits = BITSTL; if (getrendermode() < 3) bits = BITS;
else bits = BITSTL;
daydim = r<<3; daydim = r<<3;
xsiz = tilesizx[BGTILE]; tx2 = xdim/xsiz; xsiz = tilesizx[BGTILE];
ysiz = tilesizy[BGTILE]; ty2 = daydim/ysiz; tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE];
ty2 = daydim/ysiz;
for (x=0;x<=tx2;x++) for (x=0;x<=tx2;x++)
for (y=0;y<=ty2;y++) for (y=0;y<=ty2;y++)
rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim); rotatesprite(x*xsiz<<16,y*ysiz<<16,65536L,0,BGTILE,SHADE,PALETTE,bits,0,0,xdim,daydim);
xsiz = tilesizy[BORDTILE]; tx2 = xdim/xsiz; xsiz = tilesizy[BORDTILE];
tx2 = xdim/xsiz;
ysiz = tilesizx[BORDTILE]; ysiz = tilesizx[BORDTILE];
for (x=0;x<=tx2;x++) for (x=0;x<=tx2;x++)

View file

@ -40,9 +40,12 @@ int32 lastcontroltime; //MED
void setpal(struct player_struct *p) void setpal(struct player_struct *p)
{ {
if (p->heat_on) p->palette = slimepal; if (p->heat_on) p->palette = slimepal;
else if ((sector[p->cursectnum].ceilingpicnum >= FLOORSLIME)&&(sector[p->cursectnum].ceilingpicnum <=FLOORSLIME+2)) { else if ((sector[p->cursectnum].ceilingpicnum >= FLOORSLIME)&&(sector[p->cursectnum].ceilingpicnum <=FLOORSLIME+2))
{
p->palette = slimepal; p->palette = slimepal;
} else { }
else
{
if (sector[p->cursectnum].lotag == 2) p->palette = waterpal; if (sector[p->cursectnum].lotag == 2) p->palette = waterpal;
else p->palette = palette; else p->palette = palette;
@ -262,14 +265,16 @@ short aim(spritetype *s,short aang,short atwith)
long dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist; long dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist;
long xv, yv; long xv, yv;
if (s->picnum == APLAYER) { if (s->picnum == APLAYER)
{
if (!ps[s->yvel].auto_aim) if (!ps[s->yvel].auto_aim)
return -1; return -1;
if (ps[s->yvel].auto_aim == 2) if (ps[s->yvel].auto_aim == 2)
{ {
if (checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (projectile[atwith].workslike & PROJECTILE_FLAG_RPG)) if (checkspriteflagsp(atwith,SPRITE_FLAG_PROJECTILE) && (projectile[atwith].workslike & PROJECTILE_FLAG_RPG))
return -1; return -1;
else switch (dynamictostatic[atwith]) { else switch (dynamictostatic[atwith])
{
case TONGUE__STATIC: case TONGUE__STATIC:
case FREEZEBLAST__STATIC: case FREEZEBLAST__STATIC:
case SHRINKSPARK__STATIC: case SHRINKSPARK__STATIC:
@ -321,12 +326,15 @@ short aim(spritetype *s,short aang,short atwith)
if (gotshrinker && sprite[i].xrepeat < 30) if (gotshrinker && sprite[i].xrepeat < 30)
{ {
if (PN == SHARK) { if (PN == SHARK)
{
if (sprite[i].xrepeat < 20) continue; if (sprite[i].xrepeat < 20) continue;
continue; continue;
} else if ((PN >= GREENSLIME)&&(PN <= GREENSLIME+7)) {
} }
else { else if ((PN >= GREENSLIME)&&(PN <= GREENSLIME+7))
{}
else
{
continue; continue;
} }
} }
@ -751,7 +759,8 @@ short shoot(short i,short atwith)
sprite[l].xrepeat = sprite[l].yrepeat = 24; sprite[l].xrepeat = sprite[l].yrepeat = 24;
sprite[l].ang += 64-(TRAND&127); sprite[l].ang += 64-(TRAND&127);
} }
else { else
{
if (projectile[atwith].spawns >= 0) if (projectile[atwith].spawns >= 0)
{ {
wh=spawn(k,projectile[atwith].spawns); wh=spawn(k,projectile[atwith].spawns);
@ -1174,7 +1183,8 @@ DOSKIPBULLETHOLE:
if (j >= 0) if (j >= 0)
{ {
dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8);
if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) { if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN))
{
dal -= (8<<8); dal -= (8<<8);
@ -1452,7 +1462,11 @@ SKIPBULLETHOLE:
if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9]; if (hittype[i].temp_data[9]) zvel = hittype[i].temp_data[9];
oldzvel = zvel; oldzvel = zvel;
if (atwith == SPIT) { sizx = 18;sizy = 18,sz -= (10<<8); } if (atwith == SPIT)
{
sizx = 18;
sizy = 18,sz -= (10<<8);
}
else else
{ {
if (atwith == FIRELASER) if (atwith == FIRELASER)
@ -1732,7 +1746,8 @@ SKIPBULLETHOLE:
if (j >= 0) if (j >= 0)
{ {
dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); dal = ((sprite[j].xrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8);
if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) { if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN))
{
dal -= (8<<8); dal -= (8<<8);
} }
@ -2716,7 +2731,10 @@ void displayweapon(short snum)
long myaimmode = 0, myaimstat = 0, omyaimstat = 0; long myaimmode = 0, myaimstat = 0, omyaimstat = 0;
int32 mouseyaxismode = -1; int32 mouseyaxismode = -1;
static ControlInfo lastinfo = { 0,0,0,0,0,0 }; static ControlInfo lastinfo =
{
0,0,0,0,0,0
};
static int jump_input = 0; static int jump_input = 0;
@ -2751,7 +2769,8 @@ void getinput(short snum)
myaimmode = BUTTON(gamefunc_Mouse_Aiming); myaimmode = BUTTON(gamefunc_Mouse_Aiming);
else else
{ {
omyaimstat = myaimstat; myaimstat = BUTTON(gamefunc_Mouse_Aiming); omyaimstat = myaimstat;
myaimstat = BUTTON(gamefunc_Mouse_Aiming);
if (myaimstat > omyaimstat) if (myaimstat > omyaimstat)
{ {
myaimmode ^= 1; myaimmode ^= 1;
@ -2764,7 +2783,8 @@ void getinput(short snum)
if (myaimmode) i = analog_lookingupanddown; if (myaimmode) i = analog_lookingupanddown;
else i = MouseAnalogueAxes[1]; else i = MouseAnalogueAxes[1];
if (i != mouseyaxismode) { if (i != mouseyaxismode)
{
CONTROL_MapAnalogAxis(1, i, controldevice_mouse); CONTROL_MapAnalogAxis(1, i, controldevice_mouse);
mouseyaxismode = i; mouseyaxismode = i;
} }
@ -2897,10 +2917,13 @@ void getinput(short snum)
if (SmoothInput) if (SmoothInput)
{ {
if (BUTTON(gamefunc_Strafe)) { if (BUTTON(gamefunc_Strafe))
{
svel = -(info.dyaw+lastinfo.dyaw)/8; svel = -(info.dyaw+lastinfo.dyaw)/8;
lastinfo.dyaw = (lastinfo.dyaw+info.dyaw) % 8; lastinfo.dyaw = (lastinfo.dyaw+info.dyaw) % 8;
} else { }
else
{
angvel = (info.dyaw+lastinfo.dyaw)/64; angvel = (info.dyaw+lastinfo.dyaw)/64;
lastinfo.dyaw = (lastinfo.dyaw+info.dyaw) % 64; lastinfo.dyaw = (lastinfo.dyaw+info.dyaw) % 64;
} }
@ -2913,9 +2936,12 @@ void getinput(short snum)
} }
else else
{ {
if (BUTTON(gamefunc_Strafe)) { if (BUTTON(gamefunc_Strafe))
{
svel = -info.dyaw/8; svel = -info.dyaw/8;
} else { }
else
{
angvel = info.dyaw/64; angvel = info.dyaw/64;
} }
@ -3121,7 +3147,8 @@ char doincrements(struct player_struct *p)
p->quick_kick--; p->quick_kick--;
if (p->quick_kick == 8) if (p->quick_kick == 8)
shoot(p->i,KNEE); shoot(p->i,KNEE);
} else if (last_quick_kick[snum] > 0) last_quick_kick[snum]--; }
else if (last_quick_kick[snum] > 0) last_quick_kick[snum]--;
if (p->access_incs && sprite[p->i].pal != 1) if (p->access_incs && sprite[p->i].pal != 1)
{ {
@ -3136,11 +3163,14 @@ char doincrements(struct player_struct *p)
switch (sprite[p->access_spritenum].pal) switch (sprite[p->access_spritenum].pal)
{ {
case 0: case 0:
p->got_access &= (0xffff-0x1);break; p->got_access &= (0xffff-0x1);
break;
case 21: case 21:
p->got_access &= (0xffff-0x2);break; p->got_access &= (0xffff-0x2);
break;
case 23: case 23:
p->got_access &= (0xffff-0x4);break; p->got_access &= (0xffff-0x4);
break;
} }
p->access_spritenum = -1; p->access_spritenum = -1;
} }
@ -3150,11 +3180,14 @@ char doincrements(struct player_struct *p)
switch (wall[p->access_wallnum].pal) switch (wall[p->access_wallnum].pal)
{ {
case 0: case 0:
p->got_access &= (0xffff-0x1);break; p->got_access &= (0xffff-0x1);
break;
case 21: case 21:
p->got_access &= (0xffff-0x2);break; p->got_access &= (0xffff-0x2);
break;
case 23: case 23:
p->got_access &= (0xffff-0x4);break; p->got_access &= (0xffff-0x4);
break;
} }
} }
} }
@ -3580,15 +3613,20 @@ void processinput(short snum)
} }
break; break;
case RPG__STATIC: case RPG__STATIC:
i = 4; break; i = 4;
break;
case RADIUSEXPLOSION__STATIC: case RADIUSEXPLOSION__STATIC:
i = 5; break; i = 5;
break;
case SHRINKSPARK__STATIC: case SHRINKSPARK__STATIC:
i = 6; break; i = 6;
break;
case GROWSPARK__STATIC: case GROWSPARK__STATIC:
i = 8; break; i = 8;
break;
default: default:
i = 0; break; i = 0;
break;
} }
} }
Bstrcpy(name1,&ud.user_name[snum][0]); Bstrcpy(name1,&ud.user_name[snum][0]);
@ -3977,13 +4015,17 @@ void processinput(short snum)
switch (TRAND&3) switch (TRAND&3)
{ {
case 0: case 0:
j = spawn(pi,FOOTPRINTS); break; j = spawn(pi,FOOTPRINTS);
break;
case 1: case 1:
j = spawn(pi,FOOTPRINTS2); break; j = spawn(pi,FOOTPRINTS2);
break;
case 2: case 2:
j = spawn(pi,FOOTPRINTS3); break; j = spawn(pi,FOOTPRINTS3);
break;
default: default:
j = spawn(pi,FOOTPRINTS4); break; j = spawn(pi,FOOTPRINTS4);
break;
} }
sprite[j].pal = p->footprintpal; sprite[j].pal = p->footprintpal;
sprite[j].shade = p->footprintshade; sprite[j].shade = p->footprintshade;
@ -4198,7 +4240,9 @@ void processinput(short snum)
{ {
if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN))
spritesound(DUKE_LONGTERM_PAIN,pi); spritesound(DUKE_LONGTERM_PAIN,pi);
p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; p->pals[0] = 0;
p->pals[1] = 8;
p->pals[2] = 0;
p->pals_time = 32; p->pals_time = 32;
s->extra--; s->extra--;
} }
@ -4219,7 +4263,9 @@ void processinput(short snum)
{ {
if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN))
spritesound(DUKE_LONGTERM_PAIN,pi); spritesound(DUKE_LONGTERM_PAIN,pi);
p->pals[0] = 64; p->pals[1] = 64; p->pals[2] = 64; p->pals[0] = 64;
p->pals[1] = 64;
p->pals[2] = 64;
p->pals_time = 32; p->pals_time = 32;
s->extra -= 1+(TRAND&3); s->extra -= 1+(TRAND&3);
if (!isspritemakingsound(pi,SHORT_CIRCUIT)) if (!isspritemakingsound(pi,SHORT_CIRCUIT))
@ -4236,7 +4282,9 @@ void processinput(short snum)
{ {
if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN))
spritesound(DUKE_LONGTERM_PAIN,pi); spritesound(DUKE_LONGTERM_PAIN,pi);
p->pals[0] = 0; p->pals[1] = 8; p->pals[2] = 0; p->pals[0] = 0;
p->pals[1] = 8;
p->pals[2] = 0;
p->pals_time = 32; p->pals_time = 32;
s->extra -= 1+(TRAND&3); s->extra -= 1+(TRAND&3);
} }
@ -4251,7 +4299,9 @@ void processinput(short snum)
{ {
if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN)) if (!isspritemakingsound(pi,DUKE_LONGTERM_PAIN))
spritesound(DUKE_LONGTERM_PAIN,pi); spritesound(DUKE_LONGTERM_PAIN,pi);
p->pals[0] = 8; p->pals[1] = 0; p->pals[2] = 0; p->pals[0] = 8;
p->pals[1] = 0;
p->pals[2] = 0;
p->pals_time = 32; p->pals_time = 32;
s->extra -= 1+(TRAND&3); s->extra -= 1+(TRAND&3);
} }
@ -5113,46 +5163,65 @@ int getspritescore(long snum, long dapicnum)
return(120); return(120);
case FREEZEAMMO__STATIC: case FREEZEAMMO__STATIC:
if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10); else return(0); if (ps[snum].ammo_amount[FREEZE_WEAPON] < max_ammo_amount[FREEZE_WEAPON]) return(10);
else return(0);
case AMMO__STATIC: case AMMO__STATIC:
if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10); else return(0); if (ps[snum].ammo_amount[PISTOL_WEAPON] < max_ammo_amount[PISTOL_WEAPON]) return(10);
else return(0);
case BATTERYAMMO__STATIC: case BATTERYAMMO__STATIC:
if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20); else return(0); if (ps[snum].ammo_amount[CHAINGUN_WEAPON] < max_ammo_amount[CHAINGUN_WEAPON]) return(20);
else return(0);
case DEVISTATORAMMO__STATIC: case DEVISTATORAMMO__STATIC:
if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25); else return(0); if (ps[snum].ammo_amount[DEVISTATOR_WEAPON] < max_ammo_amount[DEVISTATOR_WEAPON]) return(25);
else return(0);
case RPGAMMO__STATIC: case RPGAMMO__STATIC:
if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50); else return(0); if (ps[snum].ammo_amount[RPG_WEAPON] < max_ammo_amount[RPG_WEAPON]) return(50);
else return(0);
case CRYSTALAMMO__STATIC: case CRYSTALAMMO__STATIC:
if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10); else return(0); if (ps[snum].ammo_amount[SHRINKER_WEAPON] < max_ammo_amount[SHRINKER_WEAPON]) return(10);
else return(0);
case HBOMBAMMO__STATIC: case HBOMBAMMO__STATIC:
if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30); else return(0); if (ps[snum].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) return(30);
else return(0);
case SHOTGUNAMMO__STATIC: case SHOTGUNAMMO__STATIC:
if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25); else return(0); if (ps[snum].ammo_amount[SHOTGUN_WEAPON] < max_ammo_amount[SHOTGUN_WEAPON]) return(25);
else return(0);
case COLA__STATIC: case COLA__STATIC:
if (sprite[ps[snum].i].extra < 100) return(10); else return(0); if (sprite[ps[snum].i].extra < 100) return(10);
else return(0);
case SIXPAK__STATIC: case SIXPAK__STATIC:
if (sprite[ps[snum].i].extra < 100) return(30); else return(0); if (sprite[ps[snum].i].extra < 100) return(30);
else return(0);
case FIRSTAID__STATIC: case FIRSTAID__STATIC:
if (ps[snum].firstaid_amount < 100) return(100); else return(0); if (ps[snum].firstaid_amount < 100) return(100);
else return(0);
case SHIELD__STATIC: case SHIELD__STATIC:
if (ps[snum].shield_amount < 100) return(50); else return(0); if (ps[snum].shield_amount < 100) return(50);
else return(0);
case STEROIDS__STATIC: case STEROIDS__STATIC:
if (ps[snum].steroids_amount < 400) return(30); else return(0); if (ps[snum].steroids_amount < 400) return(30);
else return(0);
case AIRTANK__STATIC: case AIRTANK__STATIC:
if (ps[snum].scuba_amount < 6400) return(30); else return(0); if (ps[snum].scuba_amount < 6400) return(30);
else return(0);
case JETPACK__STATIC: case JETPACK__STATIC:
if (ps[snum].jetpack_amount < 1600) return(100); else return(0); if (ps[snum].jetpack_amount < 1600) return(100);
else return(0);
case HEATSENSOR__STATIC: case HEATSENSOR__STATIC:
if (ps[snum].heat_amount < 1200) return(5); else return(0); if (ps[snum].heat_amount < 1200) return(5);
else return(0);
case ACCESSCARD__STATIC: case ACCESSCARD__STATIC:
return(1); return(1);
case BOOTS__STATIC: case BOOTS__STATIC:
if (ps[snum].boot_amount < 200) return(15); else return(0); if (ps[snum].boot_amount < 200) return(15);
else return(0);
case ATOMICHEALTH__STATIC: case ATOMICHEALTH__STATIC:
if (sprite[ps[snum].i].extra < max_player_health<<1) return(50); else return(0); if (sprite[ps[snum].i].extra < max_player_health<<1) return(50);
else return(0);
case HOLODUKE__STATIC: case HOLODUKE__STATIC:
if (ps[snum].holoduke_amount < 2400) return(5); else return(0); if (ps[snum].holoduke_amount < 2400) return(5);
else return(0);
case SECTOREFFECTOR__STATIC: case SECTOREFFECTOR__STATIC:
return(1); return(1);
@ -5209,7 +5278,13 @@ void computergetinput(long snum, input *syn)
damyang = sprite[p->i].ang; damyang = sprite[p->i].ang;
damysect = sprite[p->i].sectnum; damysect = sprite[p->i].sectnum;
if ((numplayers >= 2) && (snum == myconnectindex)) if ((numplayers >= 2) && (snum == myconnectindex))
{ x1 = myx; y1 = myy; z1 = myz+PHEIGHT; damyang = myang; damysect = mycursectnum; } {
x1 = myx;
y1 = myy;
z1 = myz+PHEIGHT;
damyang = myang;
damysect = mycursectnum;
}
if (!(numframes&7)) if (!(numframes&7))
{ {
@ -5235,7 +5310,11 @@ void computergetinput(long snum, input *syn)
if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[ps[i].i].sectnum)) if (!cansee(x1,y1,z1-(48<<8),damysect,x2,y2,z2-(48<<8),sprite[ps[i].i].sectnum))
dist <<= 1; dist <<= 1;
if (dist < j) { j = dist; goalplayer[snum] = i; } if (dist < j)
{
j = dist;
goalplayer[snum] = i;
}
} }
} }
@ -5253,15 +5332,20 @@ void computergetinput(long snum, input *syn)
switch (dynamictostatic[sprite[j].picnum]) switch (dynamictostatic[sprite[j].picnum])
{ {
case TONGUE__STATIC: case TONGUE__STATIC:
k = 4; break; k = 4;
break;
case FREEZEBLAST__STATIC: case FREEZEBLAST__STATIC:
k = 4; break; k = 4;
break;
case SHRINKSPARK__STATIC: case SHRINKSPARK__STATIC:
k = 16; break; k = 16;
break;
case RPG__STATIC: case RPG__STATIC:
k = 16; break; k = 16;
break;
default: default:
k = 0; break; k = 0;
break;
} }
if (k) if (k)
{ {
@ -5274,7 +5358,8 @@ void computergetinput(long snum, input *syn)
{ {
dx = sintable[(sprite[j].ang+512)&2047]; dx = sintable[(sprite[j].ang+512)&2047];
dy = sintable[sprite[j].ang&2047]; dy = sintable[sprite[j].ang&2047];
if ((x1-x3)*dy > (y1-y3)*dx) i = -k*512; else i = k*512; if ((x1-x3)*dy > (y1-y3)*dx) i = -k*512;
else i = k*512;
syn->fvel -= mulscale17(dy,i); syn->fvel -= mulscale17(dy,i);
syn->svel += mulscale17(dx,i); syn->svel += mulscale17(dx,i);
} }
@ -5319,15 +5404,22 @@ void computergetinput(long snum, input *syn)
fightdist = fdmatrix[p->curr_weapon][ps[goalplayer[snum]].curr_weapon]; fightdist = fdmatrix[p->curr_weapon][ps[goalplayer[snum]].curr_weapon];
if (fightdist < 128) fightdist = 128; if (fightdist < 128) fightdist = 128;
dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (dist == 0) dist = 1; dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
if (dist == 0) dist = 1;
daang = getangle(x2+(ps[goalplayer[snum]].posxv>>14)-x1,y2+(ps[goalplayer[snum]].posyv>>14)-y1); daang = getangle(x2+(ps[goalplayer[snum]].posxv>>14)-x1,y2+(ps[goalplayer[snum]].posyv>>14)-y1);
zang = 100-((z2-z1)*8)/dist; zang = 100-((z2-z1)*8)/dist;
fightdist = max(fightdist,(klabs(z2-z1)>>4)); fightdist = max(fightdist,(klabs(z2-z1)>>4));
if (sprite[ps[goalplayer[snum]].i].yrepeat < 32) if (sprite[ps[goalplayer[snum]].i].yrepeat < 32)
{ fightdist = 0; syn->bits &= ~(1<<2); } {
fightdist = 0;
syn->bits &= ~(1<<2);
}
if (sprite[ps[goalplayer[snum]].i].pal == 1) if (sprite[ps[goalplayer[snum]].i].pal == 1)
{ fightdist = 0; syn->bits &= ~(1<<2); } {
fightdist = 0;
syn->bits &= ~(1<<2);
}
if (dist < 256) syn->bits |= (1<<22); if (dist < 256) syn->bits |= (1<<22);
@ -5346,7 +5438,8 @@ void computergetinput(long snum, input *syn)
i += sintable[((j+15685)<<3)&2047]; i += sintable[((j+15685)<<3)&2047];
dx = sintable[(sprite[ps[goalplayer[snum]].i].ang+512)&2047]; dx = sintable[(sprite[ps[goalplayer[snum]].i].ang+512)&2047];
dy = sintable[sprite[ps[goalplayer[snum]].i].ang&2047]; dy = sintable[sprite[ps[goalplayer[snum]].i].ang&2047];
if ((x1-x2)*dy > (y1-y2)*dx) i += 8192; else i -= 8192; if ((x1-x2)*dy > (y1-y2)*dx) i += 8192;
else i -= 8192;
syn->fvel += ((sintable[(daang+1024)&2047]*i)>>17); syn->fvel += ((sintable[(daang+1024)&2047]*i)>>17);
syn->svel += ((sintable[(daang+512)&2047]*i)>>17); syn->svel += ((sintable[(daang+512)&2047]*i)>>17);
} }
@ -5374,7 +5467,8 @@ void computergetinput(long snum, input *syn)
endwall = startwall + sector[searchsect[splc]].wallnum; endwall = startwall + sector[searchsect[splc]].wallnum;
for (i=startwall,wal=&wall[startwall];i<endwall;i++,wal++) for (i=startwall,wal=&wall[startwall];i<endwall;i++,wal++)
{ {
j = wal->nextsector; if (j < 0) continue; j = wal->nextsector;
if (j < 0) continue;
dx = ((wall[wal->point2].x+wal->x)>>1); dx = ((wall[wal->point2].x+wal->x)>>1);
dy = ((wall[wal->point2].y+wal->y)>>1); dy = ((wall[wal->point2].y+wal->y)>>1);
@ -5411,7 +5505,8 @@ void computergetinput(long snum, input *syn)
startwall = sector[startsect].wallptr; startwall = sector[startsect].wallptr;
endwall = startwall+sector[startsect].wallnum; endwall = startwall+sector[startsect].wallnum;
l = 0; k = startwall; l = 0;
k = startwall;
for (i=startwall;i<endwall;i++) for (i=startwall;i<endwall;i++)
{ {
if (wall[i].nextsector != goalsect[snum]) continue; if (wall[i].nextsector != goalsect[snum]) continue;
@ -5422,10 +5517,17 @@ void computergetinput(long snum, input *syn)
// if (dx*(y2-wall[i].y) >= dy*(x2-wall[i].x)) // if (dx*(y2-wall[i].y) >= dy*(x2-wall[i].x))
if ((x3-x1)*(wall[i].y-y1) <= (y3-y1)*(wall[i].x-x1)) if ((x3-x1)*(wall[i].y-y1) <= (y3-y1)*(wall[i].x-x1))
if ((x3-x1)*(wall[wall[i].point2].y-y1) >= (y3-y1)*(wall[wall[i].point2].x-x1)) if ((x3-x1)*(wall[wall[i].point2].y-y1) >= (y3-y1)*(wall[wall[i].point2].x-x1))
{ k = i; break; } {
k = i;
break;
}
dist = ksqrt(dx*dx+dy*dy); dist = ksqrt(dx*dx+dy*dy);
if (dist > l) { l = dist; k = i; } if (dist > l)
{
l = dist;
k = i;
}
} }
goalwall[snum] = k; goalwall[snum] = k;
@ -5460,14 +5562,18 @@ void computergetinput(long snum, input *syn)
goalsect[snum] = searchsect[k]; goalsect[snum] = searchsect[k];
startwall = sector[startsect].wallptr; startwall = sector[startsect].wallptr;
endwall = startwall+sector[startsect].wallnum; endwall = startwall+sector[startsect].wallnum;
l = 0; k = startwall; l = 0;
k = startwall;
for (i=startwall;i<endwall;i++) for (i=startwall;i<endwall;i++)
{ {
dx = wall[wall[i].point2].x-wall[i].x; dx = wall[wall[i].point2].x-wall[i].x;
dy = wall[wall[i].point2].y-wall[i].y; dy = wall[wall[i].point2].y-wall[i].y;
dist = ksqrt(dx*dx+dy*dy); dist = ksqrt(dx*dx+dy*dy);
if ((wall[i].nextsector == goalsect[snum]) && (dist > l)) if ((wall[i].nextsector == goalsect[snum]) && (dist > l))
{ l = dist; k = i; } {
l = dist;
k = i;
}
} }
goalwall[snum] = k; goalwall[snum] = k;
@ -5495,14 +5601,21 @@ void computergetinput(long snum, input *syn)
if ((sprite[j].xrepeat <= 0) || (sprite[j].yrepeat <= 0)) continue; if ((sprite[j].xrepeat <= 0) || (sprite[j].yrepeat <= 0)) continue;
if (getspritescore(snum,sprite[j].picnum) <= 0) continue; if (getspritescore(snum,sprite[j].picnum) <= 0) continue;
if (cansee(x1,y1,z1-(32<<8),damysect,sprite[j].x,sprite[j].y,sprite[j].z-(4<<8),i)) if (cansee(x1,y1,z1-(32<<8),damysect,sprite[j].x,sprite[j].y,sprite[j].z-(4<<8),i))
{ goalx[snum] = sprite[j].x; goaly[snum] = sprite[j].y; goalz[snum] = sprite[j].z; goalsprite[snum] = j; break; } {
goalx[snum] = sprite[j].x;
goaly[snum] = sprite[j].y;
goalz[snum] = sprite[j].z;
goalsprite[snum] = j;
break;
}
} }
} }
} }
x2 = goalx[snum]; x2 = goalx[snum];
y2 = goaly[snum]; y2 = goaly[snum];
dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (!dist) return; dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
if (!dist) return;
daang = getangle(x2-x1,y2-y1); daang = getangle(x2-x1,y2-y1);
syn->fvel += (x2-x1)*2047/dist; syn->fvel += (x2-x1)*2047/dist;
syn->svel += (y2-y1)*2047/dist; syn->svel += (y2-y1)*2047/dist;
@ -5511,11 +5624,17 @@ void computergetinput(long snum, input *syn)
else else
goalsprite[snum] = -1; goalsprite[snum] = -1;
x3 = p->posx; y3 = p->posy; z3 = p->posz; dasect = p->cursectnum; x3 = p->posx;
y3 = p->posy;
z3 = p->posz;
dasect = p->cursectnum;
i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0);
if (!i) if (!i)
{ {
x3 = p->posx; y3 = p->posy; z3 = p->posz+(24<<8); dasect = p->cursectnum; x3 = p->posx;
y3 = p->posy;
z3 = p->posz+(24<<8);
dasect = p->cursectnum;
i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0);
} }
if (i) if (i)
@ -5547,7 +5666,12 @@ void computergetinput(long snum, input *syn)
if ((clipmovecount[snum]&31) == 2) syn->bits |= (1<<29); if ((clipmovecount[snum]&31) == 2) syn->bits |= (1<<29);
if ((clipmovecount[snum]&31) == 17) syn->bits |= (1<<22); if ((clipmovecount[snum]&31) == 17) syn->bits |= (1<<22);
if (clipmovecount[snum] > 32) { goalsect[snum] = -1; goalwall[snum] = -1; clipmovecount[snum] = 0; } if (clipmovecount[snum] > 32)
{
goalsect[snum] = -1;
goalwall[snum] = -1;
clipmovecount[snum] = 0;
}
goalsprite[snum] = -1; goalsprite[snum] = -1;
} }
@ -5558,7 +5682,8 @@ void computergetinput(long snum, input *syn)
{ {
x2 = goalx[snum]; x2 = goalx[snum];
y2 = goaly[snum]; y2 = goaly[snum];
dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (!dist) return; dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
if (!dist) return;
daang = getangle(x2-x1,y2-y1); daang = getangle(x2-x1,y2-y1);
if ((goalwall[snum] >= 0) && (dist < 4096)) if ((goalwall[snum] >= 0) && (dist < 4096))
daang = ((getangle(wall[wall[goalwall[snum]].point2].x-wall[goalwall[snum]].x,wall[wall[goalwall[snum]].point2].y-wall[goalwall[snum]].y)+1536)&2047); daang = ((getangle(wall[wall[goalwall[snum]].point2].x-wall[goalwall[snum]].x,wall[wall[goalwall[snum]].point2].y-wall[goalwall[snum]].y)+1536)&2047);

View file

@ -35,22 +35,29 @@ static int precachecount;
static void tloadtile(short tilenume, char type) static void tloadtile(short tilenume, char type)
{ {
if ((picanm[tilenume]&63) > 0) { if ((picanm[tilenume]&63) > 0)
{
int i,j; int i,j;
if ((picanm[tilenume]&192)==192) { if ((picanm[tilenume]&192)==192)
{
i = tilenume - (picanm[tilenume]&63); i = tilenume - (picanm[tilenume]&63);
j = tilenume; j = tilenume;
} else { }
else
{
i = tilenume; i = tilenume;
j = tilenume + (picanm[tilenume]&63); j = tilenume + (picanm[tilenume]&63);
} }
for (;i<=j;i++) { for (;i<=j;i++)
{
if (!(gotpic[i>>3] & pow2char[i&7])) precachecount++; if (!(gotpic[i>>3] & pow2char[i&7])) precachecount++;
gotpic[i>>3] |= pow2char[i&7]; gotpic[i>>3] |= pow2char[i&7];
precachehightile[type][i>>3] |= pow2char[i&7]; precachehightile[type][i>>3] |= pow2char[i&7];
} }
} else { }
else
{
if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) precachecount++; if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) precachecount++;
gotpic[tilenume>>3] |= pow2char[tilenume&7]; gotpic[tilenume>>3] |= pow2char[tilenume&7];
precachehightile[type][tilenume>>3] |= pow2char[tilenume&7]; precachehightile[type][tilenume>>3] |= pow2char[tilenume&7];
@ -164,23 +171,32 @@ void cachespritenum(short i)
break; break;
// caching of HUD sprites for weapons that may be in the level // caching of HUD sprites for weapons that may be in the level
case CHAINGUNSPRITE__STATIC: case CHAINGUNSPRITE__STATIC:
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1); break; for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1);
break;
case RPGSPRITE__STATIC: case RPGSPRITE__STATIC:
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1); break; for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1);
break;
case FREEZESPRITE__STATIC: case FREEZESPRITE__STATIC:
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1); break; for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1);
break;
case GROWSPRITEICON__STATIC: case GROWSPRITEICON__STATIC:
case SHRINKERSPRITE__STATIC: case SHRINKERSPRITE__STATIC:
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1); break; for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1);
break;
case HBOMBAMMO__STATIC: case HBOMBAMMO__STATIC:
case HEAVYHBOMB__STATIC: case HEAVYHBOMB__STATIC:
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1); break; for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1);
break;
case TRIPBOMBSPRITE__STATIC: case TRIPBOMBSPRITE__STATIC:
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1); break; for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1);
break;
case SHOTGUNSPRITE__STATIC: case SHOTGUNSPRITE__STATIC:
tloadtile(SHOTGUNSHELL,1); for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1); break; tloadtile(SHOTGUNSHELL,1);
for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1);
break;
case DEVISTATORSPRITE__STATIC: case DEVISTATORSPRITE__STATIC:
for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1); break; for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1);
break;
} }
@ -274,7 +290,10 @@ void precachenecessarysounds(void)
{ {
j++; j++;
if ((j&7) == 0) if ((j&7) == 0)
{ handleevents(); getpackets(); } {
handleevents();
getpackets();
}
getsound(i); getsound(i);
} }
} }
@ -298,7 +317,8 @@ void cacheit(void)
{ {
tloadtile(wall[i].picnum, 0); tloadtile(wall[i].picnum, 0);
if (wall[i].overpicnum >= 0) { if (wall[i].overpicnum >= 0)
{
tloadtile(wall[i].overpicnum, 0); tloadtile(wall[i].overpicnum, 0);
} }
} }
@ -325,17 +345,21 @@ void cacheit(void)
tc = totalclock; tc = totalclock;
j = 0; j = 0;
for (i=0;i<MAXTILES;i++) { for (i=0;i<MAXTILES;i++)
if (!(i&7) && !gotpic[i>>3]) { {
if (!(i&7) && !gotpic[i>>3])
{
i+=7; i+=7;
continue; continue;
} }
if (gotpic[i>>3] & pow2char[i&7]) { if (gotpic[i>>3] & pow2char[i&7])
{
if (waloff[i] == 0) if (waloff[i] == 0)
loadtile((short)i); loadtile((short)i);
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMOST) && defined(USE_OPENGL)
if (useprecache && !KB_KeyPressed(sc_Space)) { if (useprecache && !KB_KeyPressed(sc_Space))
{
if (precachehightile[0][i>>3] & pow2char[i&7]) if (precachehightile[0][i>>3] & pow2char[i&7])
for (k=0; k<MAXPALOOKUPS; k++) for (k=0; k<MAXPALOOKUPS; k++)
polymost_precache(i,k,0); polymost_precache(i,k,0);
@ -347,10 +371,16 @@ void cacheit(void)
#endif #endif
j++; j++;
pc++; pc++;
} else continue; }
else continue;
if ((j&7) == 0) { handleevents(); getpackets(); } if ((j&7) == 0)
if (totalclock - tc > TICRATE/4) { {
handleevents();
getpackets();
}
if (totalclock - tc > TICRATE/4)
{
sprintf(tempbuf,"Loading textures ... %ld%%\n",min(100,100*pc/precachecount)); sprintf(tempbuf,"Loading textures ... %ld%%\n",min(100,100*pc/precachecount));
dofrontscreens(tempbuf); dofrontscreens(tempbuf);
tc = totalclock; tc = totalclock;
@ -369,7 +399,9 @@ void xyzmirror(short i,short wn)
setviewtotile(wn,tilesizy[wn],tilesizx[wn]); setviewtotile(wn,tilesizy[wn],tilesizx[wn]);
drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT); drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT);
display_mirror = 1; animatesprites(SX,SY,SA,65536L); display_mirror = 0; display_mirror = 1;
animatesprites(SX,SY,SA,65536L);
display_mirror = 0;
drawmasks(); drawmasks();
setviewback(); setviewback();
@ -391,7 +423,8 @@ void vscrn(void)
x1 = scale(ss,xdim,160); x1 = scale(ss,xdim,160);
x2 = xdim-x1; x2 = xdim-x1;
y1 = ss; y2 = 200; y1 = ss;
y2 = 200;
if (ud.screen_size > 0 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_FRAGBAR) && ud.multimode > 1) if (ud.screen_size > 0 && (gametype_flags[ud.coop]&GAMETYPE_FLAG_FRAGBAR) && ud.multimode > 1)
{ {
j = 0; j = 0;
@ -440,7 +473,8 @@ void pickrandomspot(short snum)
break; break;
} }
} }
} else i = TRAND%numplayersprites; }
else i = TRAND%numplayersprites;
} }
else i = snum; else i = snum;
@ -596,9 +630,12 @@ void resetinventory(short snum)
p->inven_icon = 0; p->inven_icon = 0;
p->boot_amount = 0; p->boot_amount = 0;
p->scuba_on = 0;p->scuba_amount = 0; p->scuba_on = 0;
p->heat_amount = 0;p->heat_on = 0; p->scuba_amount = 0;
p->jetpack_on = 0;p->jetpack_amount = 0; p->heat_amount = 0;
p->heat_on = 0;
p->jetpack_on = 0;
p->jetpack_amount = 0;
p->shield_amount = max_armour_amount; p->shield_amount = max_armour_amount;
p->holoduke_on = -1; p->holoduke_on = -1;
p->holoduke_amount = 0; p->holoduke_amount = 0;
@ -686,15 +723,27 @@ void setupbackdrop(short sky)
parallaxyscale = 65536L; parallaxyscale = 65536L;
break; break;
case MOONSKY1__STATIC : case MOONSKY1__STATIC :
pskyoff[6]=1; pskyoff[1]=2; pskyoff[4]=2; pskyoff[2]=3; pskyoff[6]=1;
pskyoff[1]=2;
pskyoff[4]=2;
pskyoff[2]=3;
break; break;
case BIGORBIT1__STATIC: // orbit case BIGORBIT1__STATIC: // orbit
pskyoff[5]=1; pskyoff[6]=2; pskyoff[7]=3; pskyoff[2]=4; pskyoff[5]=1;
pskyoff[6]=2;
pskyoff[7]=3;
pskyoff[2]=4;
break; break;
case LA__STATIC: case LA__STATIC:
parallaxyscale = 16384+1024; parallaxyscale = 16384+1024;
pskyoff[0]=1; pskyoff[1]=2; pskyoff[2]=1; pskyoff[3]=3; pskyoff[0]=1;
pskyoff[4]=4; pskyoff[5]=0; pskyoff[6]=2; pskyoff[7]=3; pskyoff[1]=2;
pskyoff[2]=1;
pskyoff[3]=3;
pskyoff[4]=4;
pskyoff[5]=0;
pskyoff[6]=2;
pskyoff[7]=3;
break; break;
} }
@ -901,7 +950,8 @@ void prelevel(char g)
animwall[numanimwalls].tag = 0; animwall[numanimwalls].tag = 0;
animwall[numanimwalls].wallnum = 0; animwall[numanimwalls].wallnum = 0;
switchpicnum = wal->overpicnum; switchpicnum = wal->overpicnum;
if ((wal->overpicnum > W_FORCEFIELD)&&(wal->overpicnum <= W_FORCEFIELD+2)) { if ((wal->overpicnum > W_FORCEFIELD)&&(wal->overpicnum <= W_FORCEFIELD+2))
{
switchpicnum = W_FORCEFIELD; switchpicnum = W_FORCEFIELD;
} }
switch (dynamictostatic[switchpicnum]) switch (dynamictostatic[switchpicnum])
@ -1027,8 +1077,16 @@ void newgame(char vn,char ln,char sk)
short i; short i;
if (globalskillsound >= 0 && FXDevice >= 0 && SoundToggle) if (globalskillsound >= 0 && FXDevice >= 0 && SoundToggle)
while (issoundplaying(-1,globalskillsound)) { handleevents(); getpackets(); } while (issoundplaying(-1,globalskillsound))
else { handleevents(); getpackets(); } {
handleevents();
getpackets();
}
else
{
handleevents();
getpackets();
}
globalskillsound = -1; globalskillsound = -1;
waitforeverybody(); waitforeverybody();
@ -1238,8 +1296,10 @@ void resetpspritevars(char g)
{ {
int k; int k;
for (k=0;k<MAXPLAYERS;k++) { for (k=0;k<MAXPLAYERS;k++)
if (which_palookup == ps[k].palookup) { {
if (which_palookup == ps[k].palookup)
{
which_palookup++; which_palookup++;
if (which_palookup >= 17) if (which_palookup >= 17)
which_palookup = 9; which_palookup = 9;
@ -1261,9 +1321,11 @@ void resetpspritevars(char g)
switch (ud.pteam[j]) switch (ud.pteam[j])
{ {
case 0: case 0:
k = 3; break; k = 3;
break;
case 1: case 1:
k = 21; break; k = 21;
break;
} }
ps[j].team = ud.pteam[j]; ps[j].team = ud.pteam[j];
} }
@ -1378,7 +1440,11 @@ void waitforeverybody()
for (i=connecthead;i>=0;i=connectpoint2[i]) for (i=connecthead;i>=0;i=connectpoint2[i])
{ {
if (playerreadyflag[i] < playerreadyflag[myconnectindex]) break; if (playerreadyflag[i] < playerreadyflag[myconnectindex]) break;
if ((!networkmode) && (myconnectindex != connecthead)) { i = -1; break; } //slaves in M/S mode only wait for master if ((!networkmode) && (myconnectindex != connecthead))
{
i = -1;
break;
} //slaves in M/S mode only wait for master
} }
if (i < 0) return; if (i < 0) return;
@ -1391,7 +1457,8 @@ void dofrontscreens(char *statustext)
if (ud.recstat != 2) if (ud.recstat != 2)
{ {
if (!statustext) { if (!statustext)
{
//ps[myconnectindex].palette = palette; //ps[myconnectindex].palette = palette;
setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308 setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308
fadepal(0,0,0, 0,64,7); fadepal(0,0,0, 0,64,7);
@ -1548,7 +1615,8 @@ int enterlevel(char g)
vscrn(); vscrn();
ud.screen_size = i; ud.screen_size = i;
if (!VOLUMEONE) { if (!VOLUMEONE)
{
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
{ {
@ -1557,12 +1625,20 @@ int enterlevel(char g)
initprintf("Map %s not found!\n",boardfilename); initprintf("Map %s not found!\n",boardfilename);
//gameexit(tempbuf); //gameexit(tempbuf);
return 1; return 1;
} else { }
else
{
char *p; char *p;
strcpy(levname, boardfilename); strcpy(levname, boardfilename);
p = Bstrrchr(levname,'.'); p = Bstrrchr(levname,'.');
if (!p) strcat(levname,".mhk"); if (!p) strcat(levname,".mhk");
else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } else
{
p[1]='m';
p[2]='h';
p[3]='k';
p[4]=0;
}
if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname);
} }
} }
@ -1571,16 +1647,26 @@ int enterlevel(char g)
initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]);
//gameexit(tempbuf); //gameexit(tempbuf);
return 1; return 1;
} else { }
else
{
char *p; char *p;
strcpy(levname, level_file_names[(ud.volume_number*11)+ud.level_number]); strcpy(levname, level_file_names[(ud.volume_number*11)+ud.level_number]);
p = Bstrrchr(levname,'.'); p = Bstrrchr(levname,'.');
if (!p) strcat(levname,".mhk"); if (!p) strcat(levname,".mhk");
else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } else
{
p[1]='m';
p[2]='h';
p[3]='k';
p[4]=0;
}
if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname);
} }
} else { }
else
{
l = strlen(level_file_names[(ud.volume_number*11)+ud.level_number]); l = strlen(level_file_names[(ud.volume_number*11)+ud.level_number]);
copybufbyte(level_file_names[(ud.volume_number*11)+ud.level_number],&levname[0],l); copybufbyte(level_file_names[(ud.volume_number*11)+ud.level_number],&levname[0],l);
@ -1592,11 +1678,19 @@ int enterlevel(char g)
initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]); initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]);
//gameexit(tempbuf); //gameexit(tempbuf);
return 1; return 1;
} else { }
else
{
char *p; char *p;
p = Bstrrchr(levname,'.'); p = Bstrrchr(levname,'.');
if (!p) strcat(levname,".mhk"); if (!p) strcat(levname,".mhk");
else { p[1]='m'; p[2]='h'; p[3]='k'; p[4]=0; } else
{
p[1]='m';
p[2]='h';
p[3]='k';
p[4]=0;
}
if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname); if (!loadmaphack(levname)) initprintf("Loaded map hack file %s\n",levname);
} }
} }
@ -1636,7 +1730,8 @@ int enterlevel(char g)
if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART) if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART)
opendemowrite(); opendemowrite();
if (VOLUMEONE) { if (VOLUMEONE)
{
if (ud.level_number == 0 && ud.recstat != 2) FTA(40,&ps[myconnectindex]); if (ud.level_number == 0 && ud.recstat != 2) FTA(40,&ps[myconnectindex]);
} }

View file

@ -72,7 +72,8 @@ int32 RTS_AddFile(char *filename)
// FIXME: shared opens // FIXME: shared opens
handle = kopen4load(filename, 0); handle = kopen4load(filename, 0);
if (handle < 0) { if (handle < 0)
{
initprintf("RTS file %s was not found\n",filename); initprintf("RTS file %s was not found\n",filename);
return -1; return -1;
} }
@ -82,7 +83,8 @@ int32 RTS_AddFile(char *filename)
// WAD file // WAD file
initprintf(" Adding %s.\n",filename); initprintf(" Adding %s.\n",filename);
kread(handle, &header, sizeof(header)); kread(handle, &header, sizeof(header));
if (strncmp(header.identification,"IWAD",4)) { if (strncmp(header.identification,"IWAD",4))
{
initprintf("RTS file %s doesn't have IWAD id\n",filename); initprintf("RTS file %s doesn't have IWAD id\n",filename);
kclose(handle); kclose(handle);
return -1; return -1;
@ -91,7 +93,8 @@ int32 RTS_AddFile(char *filename)
header.infotableofs = IntelLong(header.infotableofs); header.infotableofs = IntelLong(header.infotableofs);
length = header.numlumps*sizeof(filelump_t); length = header.numlumps*sizeof(filelump_t);
fileinfo = fileinfoo = (filelump_t*)malloc(length); fileinfo = fileinfoo = (filelump_t*)malloc(length);
if (!fileinfo) { if (!fileinfo)
{
initprintf("RTS file could not allocate header info\n"); initprintf("RTS file could not allocate header info\n");
kclose(handle); kclose(handle);
return -1; return -1;
@ -103,7 +106,8 @@ int32 RTS_AddFile(char *filename)
// Fill in lumpinfo // Fill in lumpinfo
// //
lump_p = realloc(lumpinfo, (numlumps + header.numlumps)*sizeof(lumpinfo_t)); lump_p = realloc(lumpinfo, (numlumps + header.numlumps)*sizeof(lumpinfo_t));
if (!lump_p) { if (!lump_p)
{
kclose(handle); kclose(handle);
return -1; return -1;
} }

View file

@ -41,7 +41,8 @@ int loadpheader(char spot,struct savehead *saveh)
// AddLog(g_szBuf); // AddLog(g_szBuf);
if (kdfread(&bv,4,1,fil) != 1) goto corrupt; if (kdfread(&bv,4,1,fil) != 1) goto corrupt;
if (bv != BYTEVERSION) { if (bv != BYTEVERSION)
{
FTA(114,&ps[myconnectindex]); FTA(114,&ps[myconnectindex]);
kclose(fil); kclose(fil);
return 1; return 1;
@ -56,7 +57,8 @@ int loadpheader(char spot,struct savehead *saveh)
if (kdfread(saveh->boardfn,BMAX_PATH,1,fil) != 1) goto corrupt; if (kdfread(saveh->boardfn,BMAX_PATH,1,fil) != 1) goto corrupt;
if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]);
tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; tilesizx[TILE_LOADSHOT] = 200;
tilesizy[TILE_LOADSHOT] = 320;
if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt;
invalidatetile(TILE_LOADSHOT,0,255); invalidatetile(TILE_LOADSHOT,0,255);
@ -133,7 +135,8 @@ int loadplayer(signed char spot)
ready2send = 1; ready2send = 1;
FTA(124,&ps[myconnectindex]); FTA(124,&ps[myconnectindex]);
return 1; return 1;
} else ud.multimode = nump; }
else ud.multimode = nump;
if (numplayers > 1) if (numplayers > 1)
{ {
@ -151,9 +154,12 @@ int loadplayer(signed char spot)
clearsoundlocks(); clearsoundlocks();
MUSIC_StopSong(); MUSIC_StopSong();
if (numplayers > 1) { if (numplayers > 1)
{
if (kdfread(&buf,19,1,fil) != 1) goto corrupt; if (kdfread(&buf,19,1,fil) != 1) goto corrupt;
} else { }
else
{
if (kdfread(&ud.savegame[spot][0],19,1,fil) != 1) goto corrupt; if (kdfread(&ud.savegame[spot][0],19,1,fil) != 1) goto corrupt;
} }
@ -170,7 +176,8 @@ int loadplayer(signed char spot)
//Fake read because lseek won't work with compression //Fake read because lseek won't work with compression
walock[TILE_LOADSHOT] = 1; walock[TILE_LOADSHOT] = 1;
if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]); if (waloff[TILE_LOADSHOT] == 0) allocache(&waloff[TILE_LOADSHOT],320*200,&walock[TILE_LOADSHOT]);
tilesizx[TILE_LOADSHOT] = 200; tilesizy[TILE_LOADSHOT] = 320; tilesizx[TILE_LOADSHOT] = 200;
tilesizy[TILE_LOADSHOT] = 320;
if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt; if (kdfread((char *)waloff[TILE_LOADSHOT],320,200,fil) != 200) goto corrupt;
invalidatetile(TILE_LOADSHOT,0,255); invalidatetile(TILE_LOADSHOT,0,255);
@ -503,7 +510,8 @@ int saveplayer(signed char spot)
dfwrite(&ud.level_number,sizeof(ud.level_number),1,fil); dfwrite(&ud.level_number,sizeof(ud.level_number),1,fil);
dfwrite(&ud.player_skill,sizeof(ud.player_skill),1,fil); dfwrite(&ud.player_skill,sizeof(ud.player_skill),1,fil);
dfwrite(&boardfilename[0],BMAX_PATH,1,fil); dfwrite(&boardfilename[0],BMAX_PATH,1,fil);
if (!waloff[TILE_SAVESHOT]) { if (!waloff[TILE_SAVESHOT])
{
walock[TILE_SAVESHOT] = 254; walock[TILE_SAVESHOT] = 254;
allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]); allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]);
clearbuf((void*)waloff[TILE_SAVESHOT],(200*320)/4,0); clearbuf((void*)waloff[TILE_SAVESHOT],(200*320)/4,0);

View file

@ -291,8 +291,14 @@ void doanimations(void)
continue; continue;
} }
if (v > 0) { a = min(a+v,animategoal[i]); } if (v > 0)
else { a = max(a+v,animategoal[i]); } {
a = min(a+v,animategoal[i]);
}
else
{
a = max(a+v,animategoal[i]);
}
if (animateptr[i] == &sector[animatesect[i]].floorz) if (animateptr[i] == &sector[animatesect[i]].floorz)
{ {
@ -617,7 +623,8 @@ void operatesectors(short sn,short ii)
{ {
//find what direction door should open by averaging the //find what direction door should open by averaging the
// 2 neighboring points of wallfind[0] & wallfind[1]. // 2 neighboring points of wallfind[0] & wallfind[1].
i = wallfind[j]-1; if (i < startwall) i = endwall; i = wallfind[j]-1;
if (i < startwall) i = endwall;
dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x;
day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y;
if (dax2 != 0) if (dax2 != 0)
@ -641,7 +648,8 @@ void operatesectors(short sn,short ii)
} }
else else
{ {
i = wallfind[j]-1; if (i < startwall) i = endwall; i = wallfind[j]-1;
if (i < startwall) i = endwall;
dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x; dax2 = ((wall[i].x+wall[wall[wallfind[j]].point2].x)>>1)-wall[wallfind[j]].x;
day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y; day2 = ((wall[i].y+wall[wall[wallfind[j]].point2].y)>>1)-wall[wallfind[j]].y;
if (dax2 != 0) if (dax2 != 0)
@ -866,7 +874,11 @@ REDODOOR:
} }
i = nextspritestat[i]; i = nextspritestat[i];
} }
if (i<0) { OSD_Printf("WARNING: SE23 i<0!\n"); return; } // JBF if (i<0)
{
OSD_Printf("WARNING: SE23 i<0!\n");
return;
} // JBF
l = sector[SECT].lotag&0x8000; l = sector[SECT].lotag&0x8000;
if (j >= 0) if (j >= 0)
@ -1106,7 +1118,8 @@ void operateforcefields(short s, short low)
i = animwall[p].wallnum; i = animwall[p].wallnum;
if (low == wall[i].lotag || low == -1) if (low == wall[i].lotag || low == -1)
if (((wall[i].overpicnum >= W_FORCEFIELD)&&(wall[i].overpicnum <= W_FORCEFIELD+2))||(wall[i].overpicnum == BIGFORCE)) { if (((wall[i].overpicnum >= W_FORCEFIELD)&&(wall[i].overpicnum <= W_FORCEFIELD+2))||(wall[i].overpicnum == BIGFORCE))
{
animwall[p].tag = 0; animwall[p].tag = 0;
@ -1138,7 +1151,8 @@ char checkhitswitch(short snum,long w,char switchtype)
if (switchtype == 1) // A wall sprite if (switchtype == 1) // A wall sprite
{ {
lotag = sprite[w].lotag; if (lotag == 0) return 0; lotag = sprite[w].lotag;
if (lotag == 0) return 0;
hitag = sprite[w].hitag; hitag = sprite[w].hitag;
sx = sprite[w].x; sx = sprite[w].x;
sy = sprite[w].y; sy = sprite[w].y;
@ -1147,7 +1161,8 @@ char checkhitswitch(short snum,long w,char switchtype)
} }
else else
{ {
lotag = wall[w].lotag; if (lotag == 0) return 0; lotag = wall[w].lotag;
if (lotag == 0) return 0;
hitag = wall[w].hitag; hitag = wall[w].hitag;
sx = wall[w].x; sx = wall[w].x;
sy = wall[w].y; sy = wall[w].y;
@ -1173,10 +1188,12 @@ char checkhitswitch(short snum,long w,char switchtype)
|| (picnum==LOCKSWITCH1+1) || (picnum==LOCKSWITCH1+1)
|| (picnum==POWERSWITCH2+1) || (picnum==POWERSWITCH2+1)
|| (picnum==LIGHTSWITCH+1) || (picnum==LIGHTSWITCH+1)
) { )
{
switchpicnum--; switchpicnum--;
} }
if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3)) { if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3))
{
switchpicnum = MULTISWITCH; switchpicnum = MULTISWITCH;
} }
@ -1265,15 +1282,18 @@ char checkhitswitch(short snum,long w,char switchtype)
while (i >= 0) while (i >= 0)
{ {
if (lotag == SLT) { if (lotag == SLT)
{
int switchpicnum=PN; // put it in a variable so later switches don't trigger on the result of changes int switchpicnum=PN; // put it in a variable so later switches don't trigger on the result of changes
if ((switchpicnum >= MULTISWITCH) && (switchpicnum <=MULTISWITCH+3)) { if ((switchpicnum >= MULTISWITCH) && (switchpicnum <=MULTISWITCH+3))
{
sprite[i].picnum++; sprite[i].picnum++;
if (sprite[i].picnum > (MULTISWITCH+3)) if (sprite[i].picnum > (MULTISWITCH+3))
sprite[i].picnum = MULTISWITCH; sprite[i].picnum = MULTISWITCH;
} }
switch (dynamictostatic[switchpicnum]) { switch (dynamictostatic[switchpicnum])
{
case DIPSWITCH__STATIC: case DIPSWITCH__STATIC:
case TECHSWITCH__STATIC: case TECHSWITCH__STATIC:
@ -1300,7 +1320,8 @@ char checkhitswitch(short snum,long w,char switchtype)
sprite[i].picnum++; sprite[i].picnum++;
break; break;
default: default:
switch (dynamictostatic[switchpicnum-1]) { switch (dynamictostatic[switchpicnum-1])
{
case TECHSWITCH__STATIC: case TECHSWITCH__STATIC:
case DIPSWITCH__STATIC: case DIPSWITCH__STATIC:
@ -1334,14 +1355,17 @@ char checkhitswitch(short snum,long w,char switchtype)
for (i=0;i<numwalls;i++) for (i=0;i<numwalls;i++)
{ {
x = i; x = i;
if (lotag == wall[x].lotag) { if (lotag == wall[x].lotag)
if ((wall[x].picnum >= MULTISWITCH) && (wall[x].picnum <=MULTISWITCH+3)) { {
if ((wall[x].picnum >= MULTISWITCH) && (wall[x].picnum <=MULTISWITCH+3))
{
wall[x].picnum++; wall[x].picnum++;
if (wall[x].picnum > (MULTISWITCH+3)) if (wall[x].picnum > (MULTISWITCH+3))
wall[x].picnum = MULTISWITCH; wall[x].picnum = MULTISWITCH;
} }
switch (dynamictostatic[wall[x].picnum]) { switch (dynamictostatic[wall[x].picnum])
{
case DIPSWITCH__STATIC: case DIPSWITCH__STATIC:
case TECHSWITCH__STATIC: case TECHSWITCH__STATIC:
@ -1368,7 +1392,8 @@ char checkhitswitch(short snum,long w,char switchtype)
wall[x].picnum++; wall[x].picnum++;
break; break;
default: default:
switch (dynamictostatic[wall[x].picnum-1]) { switch (dynamictostatic[wall[x].picnum-1])
{
case TECHSWITCH__STATIC: case TECHSWITCH__STATIC:
case DIPSWITCH__STATIC: case DIPSWITCH__STATIC:
@ -1438,10 +1463,12 @@ char checkhitswitch(short snum,long w,char switchtype)
|| (picnum==LOCKSWITCH1+1) || (picnum==LOCKSWITCH1+1)
|| (picnum==POWERSWITCH2+1) || (picnum==POWERSWITCH2+1)
|| (picnum==LIGHTSWITCH+1) || (picnum==LIGHTSWITCH+1)
) { )
{
switchpicnum--; switchpicnum--;
} }
if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3)) { if ((picnum > MULTISWITCH)&&(picnum <= MULTISWITCH+3))
{
switchpicnum = MULTISWITCH; switchpicnum = MULTISWITCH;
} }
@ -1679,7 +1706,8 @@ void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith)
return; return;
case GLASS__STATIC: case GLASS__STATIC:
updatesector(x,y,&sn); if (sn < 0) return; updatesector(x,y,&sn);
if (sn < 0) return;
wal->overpicnum=GLASS2; wal->overpicnum=GLASS2;
lotsofglass(spr,dawallnum,10); lotsofglass(spr,dawallnum,10);
wal->cstat = 0; wal->cstat = 0;
@ -1688,11 +1716,14 @@ void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith)
wall[wal->nextwall].cstat = 0; wall[wal->nextwall].cstat = 0;
i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,ps[0].ang,0,0,spr,3); i = EGS(sn,x,y,z,SECTOREFFECTOR,0,0,0,ps[0].ang,0,0,spr,3);
SLT = 128; T2 = 5; T3 = dawallnum; SLT = 128;
T2 = 5;
T3 = dawallnum;
spritesound(GLASS_BREAKING,i); spritesound(GLASS_BREAKING,i);
return; return;
case STAINGLASS1__STATIC: case STAINGLASS1__STATIC:
updatesector(x,y,&sn); if (sn < 0) return; updatesector(x,y,&sn);
if (sn < 0) return;
lotsofcolourglass(spr,dawallnum,80); lotsofcolourglass(spr,dawallnum,80);
wal->cstat = 0; wal->cstat = 0;
if (wal->nextwall >= 0) if (wal->nextwall >= 0)
@ -1855,7 +1886,8 @@ void checkplayerhurt(struct player_struct *p,short j)
{ {
j &= (MAXSPRITES-1); j &= (MAXSPRITES-1);
if (sprite[j].picnum==CACTUS){ if (sprite[j].picnum==CACTUS)
{
if (p->hurt_delay < 8) if (p->hurt_delay < 8)
{ {
@ -1877,7 +1909,8 @@ void checkplayerhurt(struct player_struct *p,short j)
j &= (MAXWALLS-1); j &= (MAXWALLS-1);
if (p->hurt_delay > 0) p->hurt_delay--; if (p->hurt_delay > 0) p->hurt_delay--;
else if (wall[j].cstat&85) { else if (wall[j].cstat&85)
{
int switchpicnum = wall[j].overpicnum; int switchpicnum = wall[j].overpicnum;
if ((switchpicnum>W_FORCEFIELD)&&(switchpicnum<=W_FORCEFIELD+2)) if ((switchpicnum>W_FORCEFIELD)&&(switchpicnum<=W_FORCEFIELD+2))
switchpicnum=W_FORCEFIELD; switchpicnum=W_FORCEFIELD;
@ -2003,7 +2036,8 @@ void checkhitsprite(short i,short sn)
if (thisprojectile[sn].workslike & PROJECTILE_FLAG_RPG) if (thisprojectile[sn].workslike & PROJECTILE_FLAG_RPG)
rpg = 1; rpg = 1;
switchpicnum = PN; switchpicnum = PN;
if ((PN > WATERFOUNTAIN)&&(PN < WATERFOUNTAIN+3)) { if ((PN > WATERFOUNTAIN)&&(PN < WATERFOUNTAIN+3))
{
switchpicnum = WATERFOUNTAIN; switchpicnum = WATERFOUNTAIN;
} }
switch (dynamictostatic[PN]) switch (dynamictostatic[PN])
@ -2284,17 +2318,23 @@ void checkhitsprite(short i,short sn)
switch (dynamictostatic[PN]) switch (dynamictostatic[PN])
{ {
case PIPE1__STATIC: case PIPE1__STATIC:
PN=PIPE1B;break; PN=PIPE1B;
break;
case PIPE2__STATIC: case PIPE2__STATIC:
PN=PIPE2B;break; PN=PIPE2B;
break;
case PIPE3__STATIC: case PIPE3__STATIC:
PN=PIPE3B;break; PN=PIPE3B;
break;
case PIPE4__STATIC: case PIPE4__STATIC:
PN=PIPE4B;break; PN=PIPE4B;
break;
case PIPE5__STATIC: case PIPE5__STATIC:
PN=PIPE5B;break; PN=PIPE5B;
break;
case PIPE6__STATIC: case PIPE6__STATIC:
PN=PIPE6B;break; PN=PIPE6B;
break;
} }
j = spawn(i,STEAM); j = spawn(i,STEAM);
@ -2583,15 +2623,20 @@ void cheatkeys(short snum)
switch (p->inven_icon) switch (p->inven_icon)
{ {
case 4: case 4:
sb_snum |= (1<<25);break; sb_snum |= (1<<25);
break;
case 3: case 3:
sb_snum |= (1<<24);break; sb_snum |= (1<<24);
break;
case 5: case 5:
sb_snum |= (1<<15);break; sb_snum |= (1<<15);
break;
case 1: case 1:
sb_snum |= (1<<16);break; sb_snum |= (1<<16);
break;
case 2: case 2:
sb_snum |= (1<<12);break; sb_snum |= (1<<12);
break;
} }
} }
} }
@ -2716,19 +2761,26 @@ CHECKINV1:
switch (dainv) switch (dainv)
{ {
case 1: case 1:
FTA(3,p);break; FTA(3,p);
break;
case 2: case 2:
FTA(90,p);break; FTA(90,p);
break;
case 3: case 3:
FTA(91,p);break; FTA(91,p);
break;
case 4: case 4:
FTA(88,p);break; FTA(88,p);
break;
case 5: case 5:
FTA(101,p);break; FTA(101,p);
break;
case 6: case 6:
FTA(89,p);break; FTA(89,p);
break;
case 7: case 7:
FTA(6,p);break; FTA(6,p);
break;
} }
} }
@ -3428,7 +3480,11 @@ CLEARCAMERAS:
} }
if ((sync[snum].bits&(1<<29)) == 0) return; if ((sync[snum].bits&(1<<29)) == 0) return;
else if (p->newowner >= 0) { i = -1; goto CLEARCAMERAS; } else if (p->newowner >= 0)
{
i = -1;
goto CLEARCAMERAS;
}
if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1) if (neartagwall == -1 && neartagsector == -1 && neartagsprite == -1)
if (klabs(hits(p->i)) < 512) if (klabs(hits(p->i)) < 512)

View file

@ -50,15 +50,18 @@ void SoundStartup(void)
if (FXDevice < 0) return; if (FXDevice < 0) return;
status = FX_Init(FXDevice, NumVoices, NumChannels, NumBits, MixRate); status = FX_Init(FXDevice, NumVoices, NumChannels, NumBits, MixRate);
if (status == FX_Ok) { if (status == FX_Ok)
{
FX_SetVolume(FXVolume); FX_SetVolume(FXVolume);
if (ReverseStereo == 1) { if (ReverseStereo == 1)
{
FX_SetReverseStereo(!FX_GetReverseStereo()); FX_SetReverseStereo(!FX_GetReverseStereo());
} }
status = FX_SetCallBack(testcallback); status = FX_SetCallBack(testcallback);
} }
if (status != FX_Ok) { if (status != FX_Ok)
{
sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error)); sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
gameexit(tempbuf); gameexit(tempbuf);
} }
@ -81,7 +84,8 @@ void SoundShutdown(void)
return; return;
status = FX_Shutdown(); status = FX_Shutdown();
if (status != FX_Ok) { if (status != FX_Ok)
{
sprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString(FX_Error)); sprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString(FX_Error));
gameexit(tempbuf); gameexit(tempbuf);
} }
@ -350,7 +354,10 @@ int xyzsound(short num,short i,long x,long y,long z)
sndang &= 2047; sndang &= 2047;
} }
if (Sound[num].ptr == 0) { if (loadsound(num) == 0) return 0; } if (Sound[num].ptr == 0)
{
if (loadsound(num) == 0) return 0;
}
else else
{ {
if (Sound[num].lock < 200) if (Sound[num].lock < 200)
@ -420,7 +427,10 @@ void sound(short num)
} }
else pitch = pitchs; else pitch = pitchs;
if (Sound[num].ptr == 0) { if (loadsound(num) == 0) return; } if (Sound[num].ptr == 0)
{
if (loadsound(num) == 0) return;
}
else else
{ {
if (Sound[num].lock < 200) if (Sound[num].lock < 200)
@ -630,7 +640,8 @@ int isspritemakingsound(short i, int num)
int issoundplaying(short i, int num) int issoundplaying(short i, int num)
{ {
if (i == -1) { if (i == -1)
{
if (Sound[num].lock == 200) if (Sound[num].lock == 200)
return 1; return 1;
else return 0; else return 0;

View file

@ -27,12 +27,14 @@
#define TAB_CONFIG 0 #define TAB_CONFIG 0
#define TAB_MESSAGES 1 #define TAB_MESSAGES 1
static struct { static struct
{
int fullscreen; int fullscreen;
int xdim3d, ydim3d, bpp3d; int xdim3d, ydim3d, bpp3d;
int forcesetup; int forcesetup;
int usemouse, usejoy; int usemouse, usejoy;
} settings; }
settings;
extern int gtkenabled; extern int gtkenabled;
@ -64,7 +66,8 @@ static void SetPage(int n)
gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n); gtk_notebook_set_current_page(GTK_NOTEBOOK(lookup_widget(startwin,"tabs")), n);
// each control in the config page vertical layout plus the start button should be made (in)sensitive // each control in the config page vertical layout plus the start button should be made (in)sensitive
if (n == TAB_CONFIG) n = TRUE; else n = FALSE; if (n == TAB_CONFIG) n = TRUE;
else n = FALSE;
gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n); gtk_widget_set_sensitive(lookup_widget(startwin,"startbutton"), n);
gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")), gtk_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n); (GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
@ -80,10 +83,16 @@ static void PopulateForm(void)
char buf[64]; char buf[64];
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, settings.bpp3d, settings.fullscreen, 1);
if (mode3d < 0) { if (mode3d < 0)
{
int i, cd[] = { 32, 24, 16, 15, 8, 0 }; int i, cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; } for (i=0; cd[i];)
for (; cd[i]; i++) { {
if (cd[i] >= settings.bpp3d) i++;
else break;
}
for (; cd[i]; i++)
{
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1); mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue; if (mode3d < 0) continue;
settings.bpp3d = cd[i]; settings.bpp3d = cd[i];
@ -98,14 +107,16 @@ static void PopulateForm(void)
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d)); modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d); gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++) { for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp); Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
gtk_list_store_append(modes3d, &iter); gtk_list_store_append(modes3d, &iter);
gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1); gtk_list_store_set(modes3d, &iter, 0,buf, 1,i, -1);
if (i == mode3d) { if (i == mode3d)
{
g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL); g_signal_handlers_block_by_func(box3d, on_vmode3dcombo_changed, NULL);
gtk_combo_box_set_active_iter(box3d, &iter); gtk_combo_box_set_active_iter(box3d, &iter);
g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL); g_signal_handlers_unblock_by_func(box3d, on_vmode3dcombo_changed, NULL);
@ -143,7 +154,11 @@ static void on_alwaysshowcheck_toggled(GtkToggleButton *togglebutton, gpointer u
static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data) static void on_cancelbutton_clicked(GtkButton *button, gpointer user_data)
{ {
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } if (mode == TAB_CONFIG)
{
retval = 0;
gtk_main_quit();
}
else quitevent++; else quitevent++;
} }
@ -154,8 +169,7 @@ static void on_startbutton_clicked(GtkButton *button, gpointer user_data)
} }
static void on_sounddrvcombo_changed(GtkComboBox *combobox, gpointer user_data) static void on_sounddrvcombo_changed(GtkComboBox *combobox, gpointer user_data)
{ {}
}
static void on_inputmousecheck_toggled(GtkToggleButton *togglebutton, gpointer user_data) static void on_inputmousecheck_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{ {
@ -169,7 +183,11 @@ static void on_inputjoycheck_toggled(GtkToggleButton *togglebutton, gpointer use
static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
{ {
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); } if (mode == TAB_CONFIG)
{
retval = 0;
gtk_main_quit();
}
else quitevent++; else quitevent++;
return TRUE; // FALSE would let the event go through. we want the game to decide when to close return TRUE; // FALSE would let the event go through. we want the game to decide when to close
} }
@ -503,7 +521,8 @@ int startwin_open(void)
if (startwin) return 1; if (startwin) return 1;
startwin = create_window(); startwin = create_window();
if (startwin) { if (startwin)
{
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
gtk_widget_show(startwin); gtk_widget_show(startwin);
gtk_main_iteration_do(FALSE); gtk_main_iteration_do(FALSE);
@ -535,8 +554,10 @@ int startwin_puts(const char *str)
textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(textbuffer, &enditer); gtk_text_buffer_get_end_iter(textbuffer, &enditer);
for (aptr = bptr = str; *aptr != 0;) { for (aptr = bptr = str; *aptr != 0;)
switch (*bptr) { {
switch (*bptr)
{
case '\b': case '\b':
if (bptr > aptr) if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
@ -607,7 +628,8 @@ int startwin_run(void)
gtk_main(); gtk_main();
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
if (retval) { if (retval)
{
ScreenMode = settings.fullscreen; ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim3d; ScreenWidth = settings.xdim3d;
ScreenHeight = settings.ydim3d; ScreenHeight = settings.ydim3d;

View file

@ -26,17 +26,22 @@
static struct audioenumdrv *wavedevs = NULL; static struct audioenumdrv *wavedevs = NULL;
static struct { static struct
{
int fullscreen; int fullscreen;
int xdim, ydim, bpp; int xdim, ydim, bpp;
int forcesetup; int forcesetup;
int usemouse, usejoy; int usemouse, usejoy;
char selectedgrp[BMAX_PATH+1]; char selectedgrp[BMAX_PATH+1];
int game; int game;
} settings; }
settings;
static HWND startupdlg = NULL; static HWND startupdlg = NULL;
static HWND pages[3] = { NULL, NULL, NULL }; static HWND pages[3] =
{
NULL, NULL, NULL
};
static int done = -1, mode = TAB_CONFIG; static int done = -1, mode = TAB_CONFIG;
#define POPULATE_VIDEO 1 #define POPULATE_VIDEO 1
@ -49,16 +54,23 @@ static void PopulateForm(int pgs)
char buf[256]; char buf[256];
int i,j; int i,j;
if (pgs & POPULATE_VIDEO) { if (pgs & POPULATE_VIDEO)
{
int mode; int mode;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE); hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1); mode = checkvideomode(&settings.xdim, &settings.ydim, settings.bpp, settings.fullscreen, 1);
if (mode < 0) { if (mode < 0)
{
int cd[] = { 32, 24, 16, 15, 8, 0 }; int cd[] = { 32, 24, 16, 15, 8, 0 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp) i++; else break; } for (i=0; cd[i];)
for (; cd[i]; i++) { {
if (cd[i] >= settings.bpp) i++;
else break;
}
for (; cd[i]; i++)
{
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1); mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
if (mode < 0) continue; if (mode < 0) continue;
settings.bpp = cd[i]; settings.bpp = cd[i];
@ -68,7 +80,8 @@ static void PopulateForm(int pgs)
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCFULLSCREEN), (settings.fullscreen ? BST_CHECKED : BST_UNCHECKED));
ComboBox_ResetContent(hwnd); ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) { for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue; if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list // all modes get added to the 3D mode list
@ -79,24 +92,31 @@ static void PopulateForm(int pgs)
} }
} }
if (pgs & POPULATE_CONFIG) { if (pgs & POPULATE_CONFIG)
{
struct audioenumdev *d; struct audioenumdev *d;
char *n; char *n;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV); hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
ComboBox_ResetContent(hwnd); ComboBox_ResetContent(hwnd);
if (wavedevs) { if (wavedevs)
{
d = wavedevs->devs; d = wavedevs->devs;
for (i=0; wavedevs->drvs[i]; i++) { for (i=0; wavedevs->drvs[i]; i++)
{
strcpy(buf, wavedevs->drvs[i]); strcpy(buf, wavedevs->drvs[i]);
if (d->devs) { if (d->devs)
{
strcat(buf, ":"); strcat(buf, ":");
n = buf + strlen(buf); n = buf + strlen(buf);
for (j=0; d->devs[j]; j++) { for (j=0; d->devs[j]; j++)
{
strcpy(n, d->devs[j]); strcpy(n, d->devs[j]);
ComboBox_AddString(hwnd, buf); ComboBox_AddString(hwnd, buf);
} }
} else { }
else
{
ComboBox_AddString(hwnd, buf); ComboBox_AddString(hwnd, buf);
} }
d = d->next; d = d->next;
@ -109,14 +129,16 @@ static void PopulateForm(int pgs)
Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED)); Button_SetCheck(GetDlgItem(pages[TAB_CONFIG], IDCINPUTJOY), (settings.usejoy ? BST_CHECKED : BST_UNCHECKED));
} }
if (pgs & POPULATE_GAME) { if (pgs & POPULATE_GAME)
{
struct grpfile *fg; struct grpfile *fg;
int i, j; int i, j;
char buf[128+BMAX_PATH]; char buf[128+BMAX_PATH];
hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA); hwnd = GetDlgItem(pages[TAB_GAME], IDGDATA);
for (fg = foundgrps; fg; fg=fg->next) { for (fg = foundgrps; fg; fg=fg->next)
{
for (i = 0; i<numgrpfiles; i++) if (fg->crcval == grpfiles[i].crcval) break; for (i = 0; i<numgrpfiles; i++) if (fg->crcval == grpfiles[i].crcval) break;
if (i == numgrpfiles) continue; // unrecognised grp file if (i == numgrpfiles) continue; // unrecognised grp file
Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name); Bsprintf(buf, "%s\t%s", grpfiles[i].name, fg->name);
@ -129,19 +151,23 @@ static void PopulateForm(int pgs)
static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg)
{
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam))
{
case IDCFULLSCREEN: case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen; settings.fullscreen = !settings.fullscreen;
PopulateForm(POPULATE_VIDEO); PopulateForm(POPULATE_VIDEO);
return TRUE; return TRUE;
case IDCVMODE: case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) { if (HIWORD(wParam) == CBN_SELCHANGE)
{
int i; int i;
i = ComboBox_GetCurSel((HWND)lParam); i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) { if (i != CB_ERR)
{
settings.xdim = validmode[i].xdim; settings.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim; settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp; settings.bpp = validmode[i].bpp;
@ -169,15 +195,19 @@ static INT_PTR CALLBACK ConfigPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg)
{
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam))
case IDGDATA: { {
case IDGDATA:
{
int i; int i;
if (HIWORD(wParam) != LBN_SELCHANGE) break; if (HIWORD(wParam) != LBN_SELCHANGE) break;
i = ListBox_GetCurSel((HWND)lParam); i = ListBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) { if (i != CB_ERR)
{
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
settings.game = ((struct grpfile*)i)->game; settings.game = ((struct grpfile*)i)->game;
} }
@ -226,8 +256,10 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
static HBITMAP hbmp = NULL; static HBITMAP hbmp = NULL;
HDC hdc; HDC hdc;
switch (uMsg) { switch (uMsg)
case WM_INITDIALOG: { {
case WM_INITDIALOG:
{
HWND hwnd; HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart; RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0; int xoffset = 0, yoffset = 0;
@ -241,22 +273,32 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart); GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// Knock off the non-client area of the main dialogue to give just the client area // Knock off the non-client area of the main dialogue to give just the client area
rdlg.left -= chrome.left; rdlg.top -= chrome.top; rdlg.left -= chrome.left;
rdlg.right -= chrome.right; rdlg.bottom -= chrome.bottom; rdlg.top -= chrome.top;
rdlg.right -= chrome.right;
rdlg.bottom -= chrome.bottom;
// Translate them to client-relative coordinates wrt the main dialogue window // Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1; rtab.right -= rtab.left - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left;
rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1; rcancel.right -= rcancel.left - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left;
rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1; rstart.right -= rstart.left - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left;
rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length // And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1; rdlg.right -= rdlg.left - 1;
rdlg.left = 0; rdlg.top = 0; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0;
rdlg.top = 0;
// Load the bitmap into the bitmap control and fetch its dimensions // Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP)); hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
@ -267,9 +309,12 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
yoffset = r.bottom - rdlg.bottom; yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it // Shift and resize the controls that require it
rtab.left += xoffset; rtab.bottom += yoffset; rtab.left += xoffset;
rcancel.left += xoffset; rcancel.top += yoffset; rtab.bottom += yoffset;
rstart.left += xoffset; rstart.top += yoffset; rcancel.left += xoffset;
rcancel.top += yoffset;
rstart.left += xoffset;
rstart.top += yoffset;
rdlg.right += xoffset; rdlg.right += xoffset;
rdlg.bottom += yoffset; rdlg.bottom += yoffset;
@ -340,18 +385,22 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
return FALSE; return FALSE;
} }
case WM_NOTIFY: { case WM_NOTIFY:
{
LPNMHDR nmhdr = (LPNMHDR)lParam; LPNMHDR nmhdr = (LPNMHDR)lParam;
int cur; int cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break; if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0); cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) { switch (nmhdr->code)
case TCN_SELCHANGING: { {
case TCN_SELCHANGING:
{
if (cur < 0 || !pages[cur]) break; if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE); ShowWindow(pages[cur],SW_HIDE);
return TRUE; return TRUE;
} }
case TCN_SELCHANGE: { case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break; if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW); ShowWindow(pages[cur],SW_SHOW);
return TRUE; return TRUE;
@ -366,17 +415,20 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
return TRUE; return TRUE;
case WM_DESTROY: case WM_DESTROY:
if (hbmp) { if (hbmp)
{
DeleteObject(hbmp); DeleteObject(hbmp);
hbmp = NULL; hbmp = NULL;
} }
if (pages[TAB_GAME]) { if (pages[TAB_GAME])
{
DestroyWindow(pages[TAB_GAME]); DestroyWindow(pages[TAB_GAME]);
pages[TAB_GAME] = NULL; pages[TAB_GAME] = NULL;
} }
if (pages[TAB_CONFIG]) { if (pages[TAB_CONFIG])
{
DestroyWindow(pages[TAB_CONFIG]); DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL; pages[TAB_CONFIG] = NULL;
} }
@ -385,13 +437,15 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
return TRUE; return TRUE;
case WM_COMMAND: case WM_COMMAND:
switch (LOWORD(wParam)) { switch (LOWORD(wParam))
{
case WIN_STARTWIN_CANCEL: case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0; if (mode == TAB_CONFIG) done = 0;
else quitevent++; else quitevent++;
return TRUE; return TRUE;
case WIN_STARTWIN_START: case WIN_STARTWIN_START:
done = 1; return TRUE; done = 1;
return TRUE;
} }
return FALSE; return FALSE;
@ -416,7 +470,8 @@ int startwin_open(void)
icc.dwICC = ICC_TAB_CLASSES; icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc); InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc); startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) { if (startupdlg)
{
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
return 0; return 0;
@ -453,25 +508,33 @@ int startwin_puts(const char *buf)
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen); SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0); linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf; p = buf;
while (*p) { while (*p)
if (newline) { {
if (newline)
{
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n"); SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0; newline = 0;
} }
q = p; q = p;
while (*q && *q != '\n') q++; while (*q && *q != '\n') q++;
memcpy(workbuf, p, q-p); memcpy(workbuf, p, q-p);
if (*q == '\n') { if (*q == '\n')
if (!q[1]) { {
if (!q[1])
{
newline = 1; newline = 1;
workbuf[q-p] = 0; workbuf[q-p] = 0;
} else { }
else
{
workbuf[q-p] = '\r'; workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n'; workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0; workbuf[q-p+2] = 0;
} }
p = q+1; p = q+1;
} else { }
else
{
workbuf[q-p] = 0; workbuf[q-p] = 0;
p = q; p = q;
} }
@ -523,10 +586,13 @@ int startwin_run(void)
strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH); strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
PopulateForm(-1); PopulateForm(-1);
while (done < 0) { while (done < 0)
switch (GetMessage(&msg, NULL, 0,0)) { {
switch (GetMessage(&msg, NULL, 0,0))
{
case 0: case 0:
done = 1; break; done = 1;
break;
case -1: case -1:
return -1; return -1;
default: default:
@ -539,7 +605,8 @@ int startwin_run(void)
SetPage(TAB_MESSAGES); SetPage(TAB_MESSAGES);
EnableConfig(0); EnableConfig(0);
if (done) { if (done)
{
ScreenMode = settings.fullscreen; ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim; ScreenWidth = settings.xdim;
ScreenHeight = settings.ydim; ScreenHeight = settings.ydim;
@ -551,10 +618,12 @@ int startwin_run(void)
gametype = settings.game; gametype = settings.game;
} }
if (wavedevs) { if (wavedevs)
{
struct audioenumdev *d, *e; struct audioenumdev *d, *e;
free(wavedevs->drvs); free(wavedevs->drvs);
for (e=wavedevs->devs; e; e=d) { for (e=wavedevs->devs; e; e=d)
{
d = e->next; d = e->next;
if (e->devs) free(e->devs); if (e->devs) free(e->devs);
free(e); free(e);

View file

@ -45,7 +45,8 @@ char testcd(char *fn, long testsiz)
strcat(name,fn); strcat(name,fn);
driveletters = GetLogicalDrives(); driveletters = GetLogicalDrives();
for (i=2; i<26; i++) { for (i=2; i<26; i++)
{
if (!(driveletters & (1ul<<i))) continue; if (!(driveletters & (1ul<<i))) continue;
driv[0] = 'A'+i; driv[0] = 'A'+i;
if (GetDriveType(driv) != DRIVE_CDROM) continue; if (GetDriveType(driv) != DRIVE_CDROM) continue;
@ -56,7 +57,8 @@ char testcd(char *fn, long testsiz)
dalen = Bfilelength(fil); dalen = Bfilelength(fil);
Bclose(fil); Bclose(fil);
if (dalen == testsiz) { if (dalen == testsiz)
{
initprintf("Copy Protection: Found CDROM in drive %c:\n", driv[0]); initprintf("Copy Protection: Found CDROM in drive %c:\n", driv[0]);
return 0; return 0;
} }

View file

@ -72,7 +72,8 @@ void Error(char *error, ...)
Shutdown(); Shutdown();
if (error) { if (error)
{
va_start(va, error); va_start(va, error);
vsprintf(buf, error, va); vsprintf(buf, error, va);
va_end(va); va_end(va);

View file

@ -59,10 +59,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
printf("Launching EDuke32...\n\nPlease leave this window open for the entire duration of your game."); printf("Launching EDuke32...\n\nPlease leave this window open for the entire duration of your game.");
if (!CreateProcess(NULL,szCmdLine,NULL,NULL,0,0,NULL,NULL,&si,&pi)) { if (!CreateProcess(NULL,szCmdLine,NULL,NULL,0,0,NULL,NULL,&si,&pi))
{
MessageBox(0,"Failed to start eduke32.exe.", "Failure starting game", MB_OK|MB_ICONSTOP); MessageBox(0,"Failed to start eduke32.exe.", "Failure starting game", MB_OK|MB_ICONSTOP);
return 1; return 1;
} else WaitForSingleObject(pi.hProcess,INFINITE); }
else WaitForSingleObject(pi.hProcess,INFINITE);
return 0; return 0;
} }