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

File diff suppressed because it is too large Load diff

View file

@ -27,64 +27,64 @@ void endanimsounds(long fr)
{ {
switch (ud.volume_number) switch (ud.volume_number)
{ {
case 0: case 0:
break; break;
case 1:
switch (fr)
{
case 1: case 1:
sound(WIND_AMBIENCE); switch (fr)
{
case 1:
sound(WIND_AMBIENCE);
break;
case 26:
sound(ENDSEQVOL2SND1);
break;
case 36:
sound(ENDSEQVOL2SND2);
break;
case 54:
sound(THUD);
break;
case 62:
sound(ENDSEQVOL2SND3);
break;
case 75:
sound(ENDSEQVOL2SND4);
break;
case 81:
sound(ENDSEQVOL2SND5);
break;
case 115:
sound(ENDSEQVOL2SND6);
break;
case 124:
sound(ENDSEQVOL2SND7);
break;
}
break; break;
case 26: case 2:
sound(ENDSEQVOL2SND1); switch (fr)
{
case 1:
sound(WIND_REPEAT);
break;
case 98:
sound(DUKE_GRUNT);
break;
case 82+20:
sound(THUD);
sound(SQUISHED);
break;
case 104+20:
sound(ENDSEQVOL3SND3);
break;
case 114+20:
sound(ENDSEQVOL3SND2);
break;
case 158:
sound(PIPEBOMB_EXPLODE);
break;
}
break; break;
case 36:
sound(ENDSEQVOL2SND2);
break;
case 54:
sound(THUD);
break;
case 62:
sound(ENDSEQVOL2SND3);
break;
case 75:
sound(ENDSEQVOL2SND4);
break;
case 81:
sound(ENDSEQVOL2SND5);
break;
case 115:
sound(ENDSEQVOL2SND6);
break;
case 124:
sound(ENDSEQVOL2SND7);
break;
}
break;
case 2:
switch (fr)
{
case 1:
sound(WIND_REPEAT);
break;
case 98:
sound(DUKE_GRUNT);
break;
case 82+20:
sound(THUD);
sound(SQUISHED);
break;
case 104+20:
sound(ENDSEQVOL3SND3);
break;
case 114+20:
sound(ENDSEQVOL3SND2);
break;
case 158:
sound(PIPEBOMB_EXPLODE);
break;
}
break;
} }
} }
@ -92,12 +92,12 @@ void logoanimsounds(long fr)
{ {
switch (fr) switch (fr)
{ {
case 1: case 1:
sound(FLY_BY); sound(FLY_BY);
break; break;
case 19: case 19:
sound(PIPEBOMB_EXPLODE); sound(PIPEBOMB_EXPLODE);
break; break;
} }
} }
@ -105,16 +105,16 @@ void intro4animsounds(long fr)
{ {
switch (fr) switch (fr)
{ {
case 1: case 1:
sound(INTRO4_B); sound(INTRO4_B);
break; break;
case 12: case 12:
case 34: case 34:
sound(SHORT_CIRCUIT); sound(SHORT_CIRCUIT);
break; break;
case 18: case 18:
sound(INTRO4_5); sound(INTRO4_5);
break; break;
} }
} }
@ -122,18 +122,18 @@ void first4animsounds(long fr)
{ {
switch (fr) switch (fr)
{ {
case 1: case 1:
sound(INTRO4_1); sound(INTRO4_1);
break; break;
case 12: case 12:
sound(INTRO4_2); sound(INTRO4_2);
break; break;
case 7: case 7:
sound(INTRO4_3); sound(INTRO4_3);
break; break;
case 26: case 26:
sound(INTRO4_4); sound(INTRO4_4);
break; break;
} }
} }
@ -141,9 +141,9 @@ void intro42animsounds(long fr)
{ {
switch (fr) switch (fr)
{ {
case 10: case 10:
sound(INTRO4_6); sound(INTRO4_6);
break; break;
} }
} }
@ -151,12 +151,12 @@ void endanimvol41(long fr)
{ {
switch (fr) switch (fr)
{ {
case 3: case 3:
sound(DUKE_UNDERWATER); sound(DUKE_UNDERWATER);
break; break;
case 35: case 35:
sound(VOL4ENDSND1); sound(VOL4ENDSND1);
break; break;
} }
} }
@ -164,18 +164,18 @@ void endanimvol42(long fr)
{ {
switch (fr) switch (fr)
{ {
case 11: case 11:
sound(DUKE_UNDERWATER); sound(DUKE_UNDERWATER);
break; break;
case 20: case 20:
sound(VOL4ENDSND1); sound(VOL4ENDSND1);
break; break;
case 39: case 39:
sound(VOL4ENDSND2); sound(VOL4ENDSND2);
break; break;
case 50: case 50:
FX_StopAllSounds(); FX_StopAllSounds();
break; break;
} }
} }
@ -183,16 +183,16 @@ void endanimvol43(long fr)
{ {
switch (fr) switch (fr)
{ {
case 1: case 1:
sound(BOSS4_DEADSPEECH); sound(BOSS4_DEADSPEECH);
break; break;
case 40: case 40:
sound(VOL4ENDSND1); sound(VOL4ENDSND1);
sound(DUKE_UNDERWATER); sound(DUKE_UNDERWATER);
break; break;
case 50: case 50:
sound(BIGBANG); sound(BIGBANG);
break; break;
} }
} }
@ -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,15 +188,16 @@ int32 CONFIG_AnalogNameToNum(char * func)
char * CONFIG_AnalogNumToName(int32 func) char * CONFIG_AnalogNumToName(int32 func)
{ {
switch (func) { switch (func)
case analog_turning: {
return "analog_turning"; case analog_turning:
case analog_strafing: return "analog_turning";
return "analog_strafing"; case analog_strafing:
case analog_moving: return "analog_strafing";
return "analog_moving"; case analog_moving:
case analog_lookingupanddown: return "analog_moving";
return "analog_lookingupanddown"; case analog_lookingupanddown:
return "analog_lookingupanddown";
} }
return NULL; return NULL;
@ -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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -8,26 +8,30 @@
#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", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, ,
{ "Duke Nukem 3D Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL }, { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL },
{ "Duke Nukem 3D Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL }, { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL },
{ "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL }, { "Duke Nukem 3D Shareware Version", 0x983AD923, 11035779, GAMEDUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, { "Duke Nukem 3D Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL },
}; { "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL },
};
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);
continue;
} // failed to stat the file
free(fn); free(fn);
if (fg->size == st.st_size && fg->mtime == st.st_mtime) { 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

File diff suppressed because it is too large Load diff

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,30 +255,34 @@ 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 {
newbpp = Batol(parm->parms[0]); case 1: // bpp switch
break; newbpp = Batol(parm->parms[0]);
case 2: // res switch break;
newwidth = Batol(parm->parms[0]); case 2: // res switch
newheight = Batol(parm->parms[1]); newwidth = Batol(parm->parms[0]);
break; newheight = Batol(parm->parms[1]);
case 3: // res & bpp switch break;
case 4: case 3: // res & bpp switch
newwidth = Batol(parm->parms[0]); case 4:
newheight = Batol(parm->parms[1]); newwidth = Batol(parm->parms[0]);
newbpp = Batol(parm->parms[2]); newheight = Batol(parm->parms[1]);
if (parm->numparms == 4) newbpp = Batol(parm->parms[2]);
newfs = (Batol(parm->parms[3]) != 0); if (parm->numparms == 4)
break; newfs = (Batol(parm->parms[3]) != 0);
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,61 +326,76 @@ 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 {
x = Batol(parm->parms[4]); case 7: // x,y,z
y = Batol(parm->parms[5]); x = Batol(parm->parms[4]);
z = Batol(parm->parms[6]); y = Batol(parm->parms[5]);
set |= 8; z = Batol(parm->parms[6]);
case 4: // ang set |= 8;
ang = Batol(parm->parms[3]) & 2047; set |= 4; case 4: // ang
case 3: // cstat ang = Batol(parm->parms[3]) & 2047;
cstat = (unsigned short)Batol(parm->parms[2]); set |= 2; set |= 4;
case 2: // pal case 3: // cstat
pal = (unsigned char)Batol(parm->parms[1]); set |= 1; cstat = (unsigned short)Batol(parm->parms[2]);
case 1: // tile number set |= 2;
if (isdigit(parm->parms[0][0])) { case 2: // pal
picnum = (unsigned short)Batol(parm->parms[0]); pal = (unsigned char)Batol(parm->parms[1]);
} else { set |= 1;
int i,j; case 1: // tile number
for (j=0; j<2; j++) { if (isdigit(parm->parms[0][0]))
for (i=0; i<labelcnt; i++) { {
if ( picnum = (unsigned short)Batol(parm->parms[0]);
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
) {
picnum = (unsigned short)labelcode[i];
break;
}
}
if (i<labelcnt) break;
} }
if (i==labelcnt) { else
OSD_Printf("spawn: Invalid tile label given\n"); {
int i,j;
for (j=0; j<2; j++)
{
for (i=0; i<labelcnt; i++)
{
if (
(j == 0 && !Bstrcmp(label+(i<<6), parm->parms[0])) ||
(j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
)
{
picnum = (unsigned short)labelcode[i];
break;
}
}
if (i<labelcnt) break;
}
if (i==labelcnt)
{
OSD_Printf("spawn: Invalid tile label given\n");
return OSDCMD_OK;
}
}
if (picnum >= MAXTILES)
{
OSD_Printf("spawn: Invalid tile number\n");
return OSDCMD_OK; return OSDCMD_OK;
} }
} break;
default:
if (picnum >= MAXTILES) { return OSDCMD_SHOWHELP;
OSD_Printf("spawn: Invalid tile number\n");
return OSDCMD_OK;
}
break;
default:
return OSDCMD_SHOWHELP;
} }
idx = spawn(ps[myconnectindex].i, (short)picnum); idx = spawn(ps[myconnectindex].i, (short)picnum);
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,48 +539,59 @@ 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
case CVAR_INT: switch (cvar[i].type&0x7f)
case CVAR_UNSIGNEDINT:
case CVAR_BOOL:
{ {
int val; case CVAR_INT:
if (showval) { case CVAR_UNSIGNEDINT:
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr); case CVAR_BOOL:
return OSDCMD_OK; {
} int val;
if (showval)
{
OSD_Printf("\"%s\" is \"%d\"\n%s\n",cvar[i].name,*(int*)cvar[i].var,(char*)cvar[i].helpstr);
return OSDCMD_OK;
}
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); {
return OSDCMD_OK; OSD_Printf("%s value out of range\n",cvar[i].name);
return OSDCMD_OK;
}
*(int*)cvar[i].var = val;
OSD_Printf("%s %d",cvar[i].name,val);
} }
*(int*)cvar[i].var = val;
OSD_Printf("%s %d",cvar[i].name,val);
} break;
case CVAR_STRING:
{
if (showval) {
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
return OSDCMD_OK;
}
else {
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
((char*)cvar[i].var)[cvar[i].extra-1] = 0;
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
}
} break;
default:
break; break;
case CVAR_STRING:
{
if (showval)
{
OSD_Printf("\"%s\" is \"%s\"\n%s\n",cvar[i].name,(char*)cvar[i].var,(char*)cvar[i].helpstr);
return OSDCMD_OK;
}
else
{
Bstrncpy((char*)cvar[i].var, parm->parms[0], cvar[i].extra-1);
((char*)cvar[i].var)[cvar[i].extra-1] = 0;
OSD_Printf("%s %s",cvar[i].name,(char*)cvar[i].var);
}
}
break;
default:
break;
} }
if (cvar[i].type&256) if (cvar[i].type&256)
updatenames(); updatenames();
@ -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++)

File diff suppressed because it is too large Load diff

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];
@ -72,115 +79,124 @@ void cachespritenum(short i)
switch (dynamictostatic[PN]) switch (dynamictostatic[PN])
{ {
case HYDRENT__STATIC: case HYDRENT__STATIC:
tloadtile(BROKEFIREHYDRENT,1); tloadtile(BROKEFIREHYDRENT,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break; break;
case TOILET__STATIC: case TOILET__STATIC:
tloadtile(TOILETBROKE,1); tloadtile(TOILETBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break; break;
case STALL__STATIC: case STALL__STATIC:
tloadtile(STALLBROKE,1); tloadtile(STALLBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1); for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break; break;
case RUBBERCAN__STATIC: case RUBBERCAN__STATIC:
maxc = 2; maxc = 2;
break; break;
case TOILETWATER__STATIC: case TOILETWATER__STATIC:
maxc = 4; maxc = 4;
break; break;
case FEMPIC1__STATIC: case FEMPIC1__STATIC:
maxc = 44; maxc = 44;
break; break;
case LIZTROOP__STATIC: case LIZTROOP__STATIC:
case LIZTROOPRUNNING__STATIC: case LIZTROOPRUNNING__STATIC:
case LIZTROOPSHOOT__STATIC: case LIZTROOPSHOOT__STATIC:
case LIZTROOPJETPACK__STATIC: case LIZTROOPJETPACK__STATIC:
case LIZTROOPONTOILET__STATIC: case LIZTROOPONTOILET__STATIC:
case LIZTROOPDUCKING__STATIC: case LIZTROOPDUCKING__STATIC:
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1); for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1); for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1);
maxc = 0; maxc = 0;
break; break;
case WOODENHORSE__STATIC: case WOODENHORSE__STATIC:
maxc = 5;
for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1);
break;
case NEWBEAST__STATIC:
case NEWBEASTSTAYPUT__STATIC:
maxc = 90;
break;
case BOSS1__STATIC:
case BOSS2__STATIC:
case BOSS3__STATIC:
maxc = 30;
break;
case OCTABRAIN__STATIC:
case OCTABRAINSTAYPUT__STATIC:
case COMMANDER__STATIC:
case COMMANDERSTAYPUT__STATIC:
maxc = 38;
break;
case RECON__STATIC:
maxc = 13;
break;
case PIGCOP__STATIC:
case PIGCOPDIVE__STATIC:
maxc = 61;
break;
case SHARK__STATIC:
maxc = 30;
break;
case LIZMAN__STATIC:
case LIZMANSPITTING__STATIC:
case LIZMANFEEDING__STATIC:
case LIZMANJUMP__STATIC:
for (j=LIZMANHEAD1;j<LIZMANLEG1+3;j++) tloadtile(j,1);
maxc = 80;
break;
case APLAYER__STATIC:
maxc = 0;
if (ud.multimode > 1)
{
maxc = 5; maxc = 5;
for (j = 1420;j < 1420+106; j++) tloadtile(j,1); for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1);
} break;
break; case NEWBEAST__STATIC:
case ATOMICHEALTH__STATIC: case NEWBEASTSTAYPUT__STATIC:
maxc = 14; maxc = 90;
break; break;
case DRONE__STATIC: case BOSS1__STATIC:
maxc = 10; case BOSS2__STATIC:
break; case BOSS3__STATIC:
case EXPLODINGBARREL__STATIC: maxc = 30;
case SEENINE__STATIC: break;
case OOZFILTER__STATIC: case OCTABRAIN__STATIC:
maxc = 3; case OCTABRAINSTAYPUT__STATIC:
break; case COMMANDER__STATIC:
case NUKEBARREL__STATIC: case COMMANDERSTAYPUT__STATIC:
case CAMERA1__STATIC: maxc = 38;
maxc = 5; break;
break; case RECON__STATIC:
// caching of HUD sprites for weapons that may be in the level maxc = 13;
case CHAINGUNSPRITE__STATIC: break;
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1); break; case PIGCOP__STATIC:
case RPGSPRITE__STATIC: case PIGCOPDIVE__STATIC:
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1); break; maxc = 61;
case FREEZESPRITE__STATIC: break;
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1); break; case SHARK__STATIC:
case GROWSPRITEICON__STATIC: maxc = 30;
case SHRINKERSPRITE__STATIC: break;
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1); break; case LIZMAN__STATIC:
case HBOMBAMMO__STATIC: case LIZMANSPITTING__STATIC:
case HEAVYHBOMB__STATIC: case LIZMANFEEDING__STATIC:
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1); break; case LIZMANJUMP__STATIC:
case TRIPBOMBSPRITE__STATIC: for (j=LIZMANHEAD1;j<LIZMANLEG1+3;j++) tloadtile(j,1);
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1); break; maxc = 80;
case SHOTGUNSPRITE__STATIC: break;
tloadtile(SHOTGUNSHELL,1); for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1); break; case APLAYER__STATIC:
case DEVISTATORSPRITE__STATIC: maxc = 0;
for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1); break; if (ud.multimode > 1)
{
maxc = 5;
for (j = 1420;j < 1420+106; j++) tloadtile(j,1);
}
break;
case ATOMICHEALTH__STATIC:
maxc = 14;
break;
case DRONE__STATIC:
maxc = 10;
break;
case EXPLODINGBARREL__STATIC:
case SEENINE__STATIC:
case OOZFILTER__STATIC:
maxc = 3;
break;
case NUKEBARREL__STATIC:
case CAMERA1__STATIC:
maxc = 5;
break;
// caching of HUD sprites for weapons that may be in the level
case CHAINGUNSPRITE__STATIC:
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1);
break;
case RPGSPRITE__STATIC:
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1);
break;
case FREEZESPRITE__STATIC:
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1);
break;
case GROWSPRITEICON__STATIC:
case SHRINKERSPRITE__STATIC:
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1);
break;
case HBOMBAMMO__STATIC:
case HEAVYHBOMB__STATIC:
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1);
break;
case TRIPBOMBSPRITE__STATIC:
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1);
break;
case SHOTGUNSPRITE__STATIC:
tloadtile(SHOTGUNSHELL,1);
for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1);
break;
case DEVISTATORSPRITE__STATIC:
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;
@ -682,20 +719,32 @@ void setupbackdrop(short sky)
switch (dynamictostatic[sky]) switch (dynamictostatic[sky])
{ {
case CLOUDYOCEAN__STATIC: case CLOUDYOCEAN__STATIC:
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;
break; pskyoff[1]=2;
case BIGORBIT1__STATIC: // orbit pskyoff[4]=2;
pskyoff[5]=1; pskyoff[6]=2; pskyoff[7]=3; pskyoff[2]=4; pskyoff[2]=3;
break; break;
case LA__STATIC: case BIGORBIT1__STATIC: // orbit
parallaxyscale = 16384+1024; pskyoff[5]=1;
pskyoff[0]=1; pskyoff[1]=2; pskyoff[2]=1; pskyoff[3]=3; pskyoff[6]=2;
pskyoff[4]=4; pskyoff[5]=0; pskyoff[6]=2; pskyoff[7]=3; pskyoff[7]=3;
break; pskyoff[2]=4;
break;
case LA__STATIC:
parallaxyscale = 16384+1024;
pskyoff[0]=1;
pskyoff[1]=2;
pskyoff[2]=1;
pskyoff[3]=3;
pskyoff[4]=4;
pskyoff[5]=0;
pskyoff[6]=2;
pskyoff[7]=3;
break;
} }
pskybits=3; pskybits=3;
@ -721,11 +770,11 @@ void prelevel(char g)
switch (sector[i].lotag) switch (sector[i].lotag)
{ {
case 20: case 20:
case 22: case 22:
if (sector[i].floorz > sector[i].ceilingz) if (sector[i].floorz > sector[i].ceilingz)
sector[i].lotag |= 32768; sector[i].lotag |= 32768;
continue; continue;
} }
if (sector[i].ceilingstat&1) if (sector[i].ceilingstat&1)
@ -772,37 +821,37 @@ void prelevel(char g)
} }
else switch (dynamictostatic[PN]) else switch (dynamictostatic[PN])
{ {
case GPSPEED__STATIC: case GPSPEED__STATIC:
sector[SECT].extra = SLT; sector[SECT].extra = SLT;
deletesprite(i); deletesprite(i);
break; break;
case CYCLER__STATIC: case CYCLER__STATIC:
if (numcyclers >= MAXCYCLERS) if (numcyclers >= MAXCYCLERS)
{ {
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS); Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
gameexit(tempbuf); gameexit(tempbuf);
} }
cyclers[numcyclers][0] = SECT; cyclers[numcyclers][0] = SECT;
cyclers[numcyclers][1] = SLT; cyclers[numcyclers][1] = SLT;
cyclers[numcyclers][2] = SS; cyclers[numcyclers][2] = SS;
cyclers[numcyclers][3] = sector[SECT].floorshade; cyclers[numcyclers][3] = sector[SECT].floorshade;
cyclers[numcyclers][4] = SHT; cyclers[numcyclers][4] = SHT;
cyclers[numcyclers][5] = (SA == 1536); cyclers[numcyclers][5] = (SA == 1536);
numcyclers++; numcyclers++;
deletesprite(i); deletesprite(i);
break; break;
case SECTOREFFECTOR__STATIC: case SECTOREFFECTOR__STATIC:
case ACTIVATOR__STATIC: case ACTIVATOR__STATIC:
case TOUCHPLATE__STATIC: case TOUCHPLATE__STATIC:
case ACTIVATORLOCKED__STATIC: case ACTIVATORLOCKED__STATIC:
case MUSICANDSFX__STATIC: case MUSICANDSFX__STATIC:
case LOCATORS__STATIC: case LOCATORS__STATIC:
case MASTERSWITCH__STATIC: case MASTERSWITCH__STATIC:
case RESPAWN__STATIC: case RESPAWN__STATIC:
sprite[i].cstat = 0; sprite[i].cstat = 0;
break; break;
} }
i = nexti; i = nexti;
} }
@ -831,39 +880,39 @@ void prelevel(char g)
{ {
switch (dynamictostatic[PN-1]) switch (dynamictostatic[PN-1])
{ {
case DIPSWITCH__STATIC: case DIPSWITCH__STATIC:
case DIPSWITCH2__STATIC: case DIPSWITCH2__STATIC:
case PULLSWITCH__STATIC: case PULLSWITCH__STATIC:
case HANDSWITCH__STATIC: case HANDSWITCH__STATIC:
case SLOTDOOR__STATIC: case SLOTDOOR__STATIC:
case LIGHTSWITCH__STATIC: case LIGHTSWITCH__STATIC:
case SPACELIGHTSWITCH__STATIC: case SPACELIGHTSWITCH__STATIC:
case SPACEDOORSWITCH__STATIC: case SPACEDOORSWITCH__STATIC:
case FRANKENSTINESWITCH__STATIC: case FRANKENSTINESWITCH__STATIC:
case LIGHTSWITCH2__STATIC: case LIGHTSWITCH2__STATIC:
case POWERSWITCH1__STATIC: case POWERSWITCH1__STATIC:
case LOCKSWITCH1__STATIC: case LOCKSWITCH1__STATIC:
case POWERSWITCH2__STATIC: case POWERSWITCH2__STATIC:
for (j=0;j<lotaglist;j++) for (j=0;j<lotaglist;j++)
if (SLT == lotags[j]) if (SLT == lotags[j])
break; break;
if (j == lotaglist) if (j == lotaglist)
{
lotags[lotaglist] = SLT;
lotaglist++;
if (lotaglist > 64)
gameexit("\nToo many switches (64 max).");
j = headspritestat[3];
while (j >= 0)
{ {
if (sprite[j].lotag == 12 && sprite[j].hitag == SLT) lotags[lotaglist] = SLT;
hittype[j].temp_data[0] = 1; lotaglist++;
j = nextspritestat[j]; if (lotaglist > 64)
gameexit("\nToo many switches (64 max).");
j = headspritestat[3];
while (j >= 0)
{
if (sprite[j].lotag == 12 && sprite[j].hitag == SLT)
hittype[j].temp_data[0] = 1;
j = nextspritestat[j];
}
} }
} break;
break;
} }
i = nextspritestat[i]; i = nextspritestat[i];
} }
@ -901,110 +950,111 @@ 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])
{ {
case FANSHADOW__STATIC: case FANSHADOW__STATIC:
case FANSPRITE__STATIC: case FANSPRITE__STATIC:
wall->cstat |= 65; wall->cstat |= 65;
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
numanimwalls++; numanimwalls++;
break; break;
case W_FORCEFIELD__STATIC: case W_FORCEFIELD__STATIC:
if (wal->overpicnum==W_FORCEFIELD__STATIC) if (wal->overpicnum==W_FORCEFIELD__STATIC)
for (j=0;j<3;j++) for (j=0;j<3;j++)
tloadtile(W_FORCEFIELD+j, 0); tloadtile(W_FORCEFIELD+j, 0);
if (wal->shade > 31) if (wal->shade > 31)
wal->cstat = 0; wal->cstat = 0;
else wal->cstat |= 85+256; else wal->cstat |= 85+256;
if (wal->lotag && wal->nextwall >= 0) if (wal->lotag && wal->nextwall >= 0)
wall[wal->nextwall].lotag = wall[wal->nextwall].lotag =
wal->lotag; wal->lotag;
case BIGFORCE__STATIC: case BIGFORCE__STATIC:
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
numanimwalls++; numanimwalls++;
continue; continue;
} }
wal->extra = -1; wal->extra = -1;
switch (dynamictostatic[wal->picnum]) switch (dynamictostatic[wal->picnum])
{ {
case WATERTILE2__STATIC: case WATERTILE2__STATIC:
for (j=0;j<3;j++) for (j=0;j<3;j++)
tloadtile(wal->picnum+j, 0); tloadtile(wal->picnum+j, 0);
break; break;
case TECHLIGHT2__STATIC: case TECHLIGHT2__STATIC:
case TECHLIGHT4__STATIC: case TECHLIGHT4__STATIC:
tloadtile(wal->picnum, 0); tloadtile(wal->picnum, 0);
break; break;
case W_TECHWALL1__STATIC: case W_TECHWALL1__STATIC:
case W_TECHWALL2__STATIC: case W_TECHWALL2__STATIC:
case W_TECHWALL3__STATIC: case W_TECHWALL3__STATIC:
case W_TECHWALL4__STATIC: case W_TECHWALL4__STATIC:
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
// animwall[numanimwalls].tag = -1; // animwall[numanimwalls].tag = -1;
numanimwalls++; numanimwalls++;
break; break;
case SCREENBREAK6__STATIC: case SCREENBREAK6__STATIC:
case SCREENBREAK7__STATIC: case SCREENBREAK7__STATIC:
case SCREENBREAK8__STATIC: case SCREENBREAK8__STATIC:
for (j=SCREENBREAK6;j<SCREENBREAK9;j++) for (j=SCREENBREAK6;j<SCREENBREAK9;j++)
tloadtile(j, 0); tloadtile(j, 0);
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = -1; animwall[numanimwalls].tag = -1;
numanimwalls++; numanimwalls++;
break; break;
case FEMPIC1__STATIC: case FEMPIC1__STATIC:
case FEMPIC2__STATIC: case FEMPIC2__STATIC:
case FEMPIC3__STATIC: case FEMPIC3__STATIC:
wal->extra = wal->picnum; wal->extra = wal->picnum;
animwall[numanimwalls].tag = -1; animwall[numanimwalls].tag = -1;
if (ud.lockout) if (ud.lockout)
{ {
if (wal->picnum == FEMPIC1) if (wal->picnum == FEMPIC1)
wal->picnum = BLANKSCREEN; wal->picnum = BLANKSCREEN;
else wal->picnum = SCREENBREAK6; else wal->picnum = SCREENBREAK6;
} }
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum; animwall[numanimwalls].tag = wal->picnum;
numanimwalls++; numanimwalls++;
break; break;
case SCREENBREAK1__STATIC: case SCREENBREAK1__STATIC:
case SCREENBREAK2__STATIC: case SCREENBREAK2__STATIC:
case SCREENBREAK3__STATIC: case SCREENBREAK3__STATIC:
case SCREENBREAK4__STATIC: case SCREENBREAK4__STATIC:
case SCREENBREAK5__STATIC: case SCREENBREAK5__STATIC:
case SCREENBREAK9__STATIC: case SCREENBREAK9__STATIC:
case SCREENBREAK10__STATIC: case SCREENBREAK10__STATIC:
case SCREENBREAK11__STATIC: case SCREENBREAK11__STATIC:
case SCREENBREAK12__STATIC: case SCREENBREAK12__STATIC:
case SCREENBREAK13__STATIC: case SCREENBREAK13__STATIC:
case SCREENBREAK14__STATIC: case SCREENBREAK14__STATIC:
case SCREENBREAK15__STATIC: case SCREENBREAK15__STATIC:
case SCREENBREAK16__STATIC: case SCREENBREAK16__STATIC:
case SCREENBREAK17__STATIC: case SCREENBREAK17__STATIC:
case SCREENBREAK18__STATIC: case SCREENBREAK18__STATIC:
case SCREENBREAK19__STATIC: case SCREENBREAK19__STATIC:
animwall[numanimwalls].wallnum = i; animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum; animwall[numanimwalls].tag = wal->picnum;
numanimwalls++; numanimwalls++;
break; break;
} }
} }
@ -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;
@ -1260,10 +1320,12 @@ void resetpspritevars(char g)
{ {
switch (ud.pteam[j]) switch (ud.pteam[j])
{ {
case 0: case 0:
k = 3; break; k = 3;
case 1: break;
k = 21; break; case 1:
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,23 +1730,24 @@ 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]);
} }
for (i=connecthead;i>=0;i=connectpoint2[i]) for (i=connecthead;i>=0;i=connectpoint2[i])
switch (dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum]) switch (dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum])
{ {
case HURTRAIL__STATIC: case HURTRAIL__STATIC:
case FLOORSLIME__STATIC: case FLOORSLIME__STATIC:
case FLOORPLASMA__STATIC: case FLOORPLASMA__STATIC:
resetweapons(i); resetweapons(i);
resetinventory(i); resetinventory(i);
ps[i].gotweapon[PISTOL_WEAPON] = 0; ps[i].gotweapon[PISTOL_WEAPON] = 0;
ps[i].ammo_amount[PISTOL_WEAPON] = 0; ps[i].ammo_amount[PISTOL_WEAPON] = 0;
ps[i].curr_weapon = KNEE_WEAPON; ps[i].curr_weapon = KNEE_WEAPON;
ps[i].kickback_pic = 0; ps[i].kickback_pic = 0;
break; break;
} }
//PREMAP.C - replace near the my's at the end of the file //PREMAP.C - replace near the my's at the end of the file

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);
@ -372,13 +379,13 @@ int loadplayer(signed char spot)
for (x=0;x<numanimwalls;x++) for (x=0;x<numanimwalls;x++)
switch (dynamictostatic[wall[animwall[x].wallnum].picnum]) switch (dynamictostatic[wall[animwall[x].wallnum].picnum])
{ {
case FEMPIC1__STATIC: case FEMPIC1__STATIC:
wall[animwall[x].wallnum].picnum = BLANKSCREEN; wall[animwall[x].wallnum].picnum = BLANKSCREEN;
break; break;
case FEMPIC2__STATIC: case FEMPIC2__STATIC:
case FEMPIC3__STATIC: case FEMPIC3__STATIC:
wall[animwall[x].wallnum].picnum = SCREENBREAK6; wall[animwall[x].wallnum].picnum = SCREENBREAK6;
break; break;
} }
} }
@ -390,31 +397,31 @@ int loadplayer(signed char spot)
{ {
switch (sprite[k].lotag) switch (sprite[k].lotag)
{ {
case 31: case 31:
setinterpolation(&sector[sprite[k].sectnum].floorz); setinterpolation(&sector[sprite[k].sectnum].floorz);
break; break;
case 32: case 32:
setinterpolation(&sector[sprite[k].sectnum].ceilingz); setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break; break;
case 25: case 25:
setinterpolation(&sector[sprite[k].sectnum].floorz); setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz); setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break; break;
case 17: case 17:
setinterpolation(&sector[sprite[k].sectnum].floorz); setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz); setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break; break;
case 0: case 0:
case 5: case 5:
case 6: case 6:
case 11: case 11:
case 14: case 14:
case 15: case 15:
case 16: case 16:
case 26: case 26:
case 30: case 30:
setsectinterpolate(k); setsectinterpolate(k);
break; break;
} }
k = nextspritestat[k]; k = nextspritestat[k];
@ -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);

File diff suppressed because it is too large Load diff

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);
} }
@ -314,20 +318,20 @@ int xyzsound(short num,short i,long x,long y,long z)
switch (num) switch (num)
{ {
case PIPEBOMB_EXPLODE: case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE: case LASERTRIP_EXPLODE:
case RPG_EXPLODE: case RPG_EXPLODE:
if (sndist > (6144)) if (sndist > (6144))
sndist = 6144; sndist = 6144;
if (sector[ps[screenpeek].cursectnum].lotag == 2) if (sector[ps[screenpeek].cursectnum].lotag == 2)
pitch -= 1024; pitch -= 1024;
break; break;
default: default:
if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
pitch = -768; pitch = -768;
if (sndist > 31444 && PN != MUSICANDSFX) if (sndist > 31444 && PN != MUSICANDSFX)
return -1; return -1;
break; break;
} }
if (ps[screenpeek].sound_pitch) pitch += ps[screenpeek].sound_pitch; if (ps[screenpeek].sound_pitch) pitch += ps[screenpeek].sound_pitch;
@ -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)
@ -548,17 +558,17 @@ void pan3dsound(void)
switch (j) switch (j)
{ {
case PIPEBOMB_EXPLODE: case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE: case LASERTRIP_EXPLODE:
case RPG_EXPLODE: case RPG_EXPLODE:
if (sndist > (6144)) sndist = (6144); if (sndist > (6144)) sndist = (6144);
break; break;
default: default:
if (sndist > 31444 && PN != MUSICANDSFX) if (sndist > 31444 && PN != MUSICANDSFX)
{ {
stopsound(j); stopsound(j);
continue; continue;
} }
} }
if (Sound[j].ptr == 0 && loadsound(j) == 0) continue; if (Sound[j].ptr == 0 && loadsound(j) == 0) continue;
@ -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,33 +554,35 @@ 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) { {
case '\b': switch (*bptr)
if (bptr > aptr) {
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1); case '\b':
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
#if GTK_CHECK_VERSION(2,6,0) #if GTK_CHECK_VERSION(2,6,0)
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE); gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
#else #else
{ {
GtkTextIter iter2 = enditer; GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2); gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere! //FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer)) if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE); gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
} }
#endif #endif
aptr = ++bptr; aptr = ++bptr;
break; break;
case 0: case 0:
if (bptr > aptr) if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)); gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr; aptr = bptr;
break; break;
case '\r': // FIXME case '\r': // FIXME
default: default:
bptr++; bptr++;
break; break;
} }
} }
@ -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,66 +151,74 @@ 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: {
switch (LOWORD(wParam)) { case WM_COMMAND:
case IDCFULLSCREEN: switch (LOWORD(wParam))
settings.fullscreen = !settings.fullscreen; {
PopulateForm(POPULATE_VIDEO); case IDCFULLSCREEN:
return TRUE; settings.fullscreen = !settings.fullscreen;
case IDCVMODE: PopulateForm(POPULATE_VIDEO);
if (HIWORD(wParam) == CBN_SELCHANGE) { return TRUE;
int i; case IDCVMODE:
i = ComboBox_GetCurSel((HWND)lParam); if (HIWORD(wParam) == CBN_SELCHANGE)
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i); {
if (i != CB_ERR) { int i;
settings.xdim = validmode[i].xdim; i = ComboBox_GetCurSel((HWND)lParam);
settings.ydim = validmode[i].ydim; if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
settings.bpp = validmode[i].bpp; if (i != CB_ERR)
} {
settings.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp;
}
}
return TRUE;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
case IDCINPUTMOUSE:
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
return TRUE;
case IDCINPUTJOY:
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
return TRUE;
default:
break;
} }
return TRUE; break;
case IDCALWAYSSHOW:
settings.forcesetup = IsDlgButtonChecked(hwndDlg, IDCALWAYSSHOW) == BST_CHECKED;
return TRUE;
case IDCINPUTMOUSE:
settings.usemouse = IsDlgButtonChecked(hwndDlg, IDCINPUTMOUSE) == BST_CHECKED;
return TRUE;
case IDCINPUTJOY:
settings.usejoy = IsDlgButtonChecked(hwndDlg, IDCINPUTJOY) == BST_CHECKED;
return TRUE;
default: default:
break; break;
}
break;
default:
break;
} }
return FALSE; return FALSE;
} }
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: {
switch (LOWORD(wParam)) { case WM_COMMAND:
case IDGDATA: { switch (LOWORD(wParam))
int i; {
if (HIWORD(wParam) != LBN_SELCHANGE) break; case IDGDATA:
i = ListBox_GetCurSel((HWND)lParam); {
if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i); int i;
if (i != CB_ERR) { if (HIWORD(wParam) != LBN_SELCHANGE) break;
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name); i = ListBox_GetCurSel((HWND)lParam);
settings.game = ((struct grpfile*)i)->game; if (i != CB_ERR) i = ListBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR)
{
strcpy(settings.selectedgrp, ((struct grpfile*)i)->name);
settings.game = ((struct grpfile*)i)->game;
}
return TRUE;
}
default:
break;
} }
return TRUE; break;
}
default: default:
break; break;
}
break;
default:
break;
} }
return FALSE; return FALSE;
} }
@ -226,182 +256,206 @@ 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: { {
HWND hwnd; case WM_INITDIALOG:
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0;
// Fetch the positions (in screen coordinates) of all the windows we need to tweak
ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
// 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.right -= chrome.right; rdlg.bottom -= chrome.bottom;
// Translate them to client-relative coordinates wrt the main dialogue window
rtab.right -= rtab.left - 1; rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left; rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1; rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left; rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1; rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left; rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1; rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0; rdlg.top = 0;
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
GetClientRect(hwnd, &r);
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
// Shift and resize the controls that require it
rtab.left += xoffset; rtab.bottom += yoffset;
rcancel.left += xoffset; rcancel.top += yoffset;
rstart.left += xoffset; rstart.top += yoffset;
rdlg.right += xoffset;
rdlg.bottom += yoffset;
// Move the controls to their new positions
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
// Move the main dialogue to the centre of the screen
hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control
{ {
TCITEM tab; HWND hwnd;
RECT r, rdlg, chrome, rtab, rcancel, rstart;
int xoffset = 0, yoffset = 0;
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL); // Fetch the positions (in screen coordinates) of all the windows we need to tweak
ZeroMemory(&chrome, sizeof(chrome));
AdjustWindowRect(&chrome, GetWindowLong(hwndDlg, GWL_STYLE), FALSE);
GetWindowRect(hwndDlg, &rdlg);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), &rtab);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), &rcancel);
GetWindowRect(GetDlgItem(hwndDlg, WIN_STARTWIN_START), &rstart);
ZeroMemory(&tab, sizeof(tab)); // Knock off the non-client area of the main dialogue to give just the client area
tab.mask = TCIF_TEXT; rdlg.left -= chrome.left;
tab.pszText = TEXT("Configuration"); rdlg.top -= chrome.top;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); rdlg.right -= chrome.right;
tab.mask = TCIF_TEXT; rdlg.bottom -= chrome.bottom;
tab.pszText = TEXT("Game");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages // Translate them to client-relative coordinates wrt the main dialogue window
ZeroMemory(&r, sizeof(r)); rtab.right -= rtab.left - 1;
rtab.bottom -= rtab.top - 1;
rtab.left -= rdlg.left;
rtab.top -= rdlg.top;
rcancel.right -= rcancel.left - 1;
rcancel.bottom -= rcancel.top - 1;
rcancel.left -= rdlg.left;
rcancel.top -= rdlg.top;
rstart.right -= rstart.left - 1;
rstart.bottom -= rstart.top - 1;
rstart.left -= rdlg.left;
rstart.top -= rdlg.top;
// And then convert the main dialogue coordinates to just width/length
rdlg.right -= rdlg.left - 1;
rdlg.bottom -= rdlg.top - 1;
rdlg.left = 0;
rdlg.top = 0;
// Load the bitmap into the bitmap control and fetch its dimensions
hbmp = LoadBitmap((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(RSRC_BMP));
hwnd = GetDlgItem(hwndDlg,WIN_STARTWIN_BITMAP);
SendMessage(hwnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hbmp);
GetClientRect(hwnd, &r); GetClientRect(hwnd, &r);
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r); xoffset = r.right;
r.right -= r.left-1; yoffset = r.bottom - rdlg.bottom;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// Create the pages and position them in the tab control, but hide them // Shift and resize the controls that require it
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(), rtab.left += xoffset;
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc); rtab.bottom += yoffset;
pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(), rcancel.left += xoffset;
MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc); rcancel.top += yoffset;
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES); rstart.left += xoffset;
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); rstart.top += yoffset;
SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); rdlg.right += xoffset;
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW); rdlg.bottom += yoffset;
// Tell the editfield acting as the console to exclude the width of the scrollbar // Move the controls to their new positions
GetClientRect(pages[TAB_MESSAGES],&r); MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL), rtab.left, rtab.top, rtab.right, rtab.bottom, FALSE);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4; MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_CANCEL), rcancel.left, rcancel.top, rcancel.right, rcancel.bottom, FALSE);
r.left = r.top = 0; MoveWindow(GetDlgItem(hwndDlg, WIN_STARTWIN_START), rstart.left, rstart.top, rstart.right, rstart.bottom, FALSE);
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
// Set a tab stop in the game data listbox // Move the main dialogue to the centre of the screen
hdc = GetDC(NULL);
rdlg.left = (GetDeviceCaps(hdc, HORZRES) - rdlg.right) / 2;
rdlg.top = (GetDeviceCaps(hdc, VERTRES) - rdlg.bottom) / 2;
ReleaseDC(NULL, hdc);
MoveWindow(hwndDlg, rdlg.left + chrome.left, rdlg.top + chrome.left,
rdlg.right + (-chrome.left+chrome.right), rdlg.bottom + (-chrome.top+chrome.bottom), TRUE);
// Add tabs to the tab control
{ {
DWORD tabs[1] = { 150 }; TCITEM tab;
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
hwnd = GetDlgItem(hwndDlg, WIN_STARTWIN_TABCTL);
ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Configuration");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Game");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages");
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r);
SendMessage(hwnd, TCM_ADJUSTRECT, FALSE, (LPARAM)&r);
r.right -= r.left-1;
r.bottom -= r.top-1;
r.top += rtab.top;
r.left += rtab.left;
// Create the pages and position them in the tab control, but hide them
pages[TAB_CONFIG] = CreateDialog((HINSTANCE)win_gethinstance(),
MAKEINTRESOURCE(WIN_STARTWINPAGE_CONFIG), hwndDlg, ConfigPageProc);
pages[TAB_GAME] = CreateDialog((HINSTANCE)win_gethinstance(),
MAKEINTRESOURCE(WIN_STARTWINPAGE_GAME), hwndDlg, GamePageProc);
pages[TAB_MESSAGES] = GetDlgItem(hwndDlg, WIN_STARTWIN_MESSAGES);
SetWindowPos(pages[TAB_CONFIG], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_GAME], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
SetWindowPos(pages[TAB_MESSAGES], hwnd,r.left,r.top,r.right,r.bottom,SWP_HIDEWINDOW);
// Tell the editfield acting as the console to exclude the width of the scrollbar
GetClientRect(pages[TAB_MESSAGES],&r);
r.right -= GetSystemMetrics(SM_CXVSCROLL)+4;
r.left = r.top = 0;
SendMessage(pages[TAB_MESSAGES], EM_SETRECTNP,0,(LPARAM)&r);
// Set a tab stop in the game data listbox
{
DWORD tabs[1] = { 150 };
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
}
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
SetWindowText(hwndDlg, apptitle);
} }
return FALSE;
SetFocus(GetDlgItem(hwndDlg, WIN_STARTWIN_START));
SetWindowText(hwndDlg, apptitle);
}
return FALSE;
}
case WM_NOTIFY: {
LPNMHDR nmhdr = (LPNMHDR)lParam;
int cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code) {
case TCN_SELCHANGING: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE: {
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
}
case WM_CLOSE:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WM_DESTROY:
if (hbmp) {
DeleteObject(hbmp);
hbmp = NULL;
} }
if (pages[TAB_GAME]) { case WM_NOTIFY:
DestroyWindow(pages[TAB_GAME]); {
pages[TAB_GAME] = NULL; LPNMHDR nmhdr = (LPNMHDR)lParam;
int cur;
if (nmhdr->idFrom != WIN_STARTWIN_TABCTL) break;
cur = (int)SendMessage(nmhdr->hwndFrom, TCM_GETCURSEL,0,0);
switch (nmhdr->code)
{
case TCN_SELCHANGING:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_HIDE);
return TRUE;
}
case TCN_SELCHANGE:
{
if (cur < 0 || !pages[cur]) break;
ShowWindow(pages[cur],SW_SHOW);
return TRUE;
}
}
break;
} }
if (pages[TAB_CONFIG]) { case WM_CLOSE:
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
startupdlg = NULL;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
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:
done = 1; return TRUE;
}
return FALSE;
case WM_CTLCOLORSTATIC: case WM_DESTROY:
if ((HWND)lParam == pages[TAB_MESSAGES]) if (hbmp)
return (BOOL)GetSysColorBrush(COLOR_WINDOW); {
break; DeleteObject(hbmp);
hbmp = NULL;
}
default: if (pages[TAB_GAME])
break; {
DestroyWindow(pages[TAB_GAME]);
pages[TAB_GAME] = NULL;
}
if (pages[TAB_CONFIG])
{
DestroyWindow(pages[TAB_CONFIG]);
pages[TAB_CONFIG] = NULL;
}
startupdlg = NULL;
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case WIN_STARTWIN_CANCEL:
if (mode == TAB_CONFIG) done = 0;
else quitevent++;
return TRUE;
case WIN_STARTWIN_START:
done = 1;
return TRUE;
}
return FALSE;
case WM_CTLCOLORSTATIC:
if ((HWND)lParam == pages[TAB_MESSAGES])
return (BOOL)GetSysColorBrush(COLOR_WINDOW);
break;
default:
break;
} }
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,23 +586,27 @@ 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)) { {
case 0: switch (GetMessage(&msg, NULL, 0,0))
done = 1; break; {
case -1: case 0:
return -1; done = 1;
default: break;
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; case -1:
TranslateMessage(&msg); return -1;
DispatchMessage(&msg); default:
break; if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
} }
} }
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;
} }