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)
{
case 0:
break;
case 1:
switch (fr)
{
case 0:
break;
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;
case 26:
sound(ENDSEQVOL2SND1);
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;
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)
{
case 1:
sound(FLY_BY);
break;
case 19:
sound(PIPEBOMB_EXPLODE);
break;
case 1:
sound(FLY_BY);
break;
case 19:
sound(PIPEBOMB_EXPLODE);
break;
}
}
@ -105,16 +105,16 @@ void intro4animsounds(long fr)
{
switch (fr)
{
case 1:
sound(INTRO4_B);
break;
case 12:
case 34:
sound(SHORT_CIRCUIT);
break;
case 18:
sound(INTRO4_5);
break;
case 1:
sound(INTRO4_B);
break;
case 12:
case 34:
sound(SHORT_CIRCUIT);
break;
case 18:
sound(INTRO4_5);
break;
}
}
@ -122,18 +122,18 @@ void first4animsounds(long fr)
{
switch (fr)
{
case 1:
sound(INTRO4_1);
break;
case 12:
sound(INTRO4_2);
break;
case 7:
sound(INTRO4_3);
break;
case 26:
sound(INTRO4_4);
break;
case 1:
sound(INTRO4_1);
break;
case 12:
sound(INTRO4_2);
break;
case 7:
sound(INTRO4_3);
break;
case 26:
sound(INTRO4_4);
break;
}
}
@ -141,9 +141,9 @@ void intro42animsounds(long fr)
{
switch (fr)
{
case 10:
sound(INTRO4_6);
break;
case 10:
sound(INTRO4_6);
break;
}
}
@ -151,12 +151,12 @@ void endanimvol41(long fr)
{
switch (fr)
{
case 3:
sound(DUKE_UNDERWATER);
break;
case 35:
sound(VOL4ENDSND1);
break;
case 3:
sound(DUKE_UNDERWATER);
break;
case 35:
sound(VOL4ENDSND1);
break;
}
}
@ -164,18 +164,18 @@ void endanimvol42(long fr)
{
switch (fr)
{
case 11:
sound(DUKE_UNDERWATER);
break;
case 20:
sound(VOL4ENDSND1);
break;
case 39:
sound(VOL4ENDSND2);
break;
case 50:
FX_StopAllSounds();
break;
case 11:
sound(DUKE_UNDERWATER);
break;
case 20:
sound(VOL4ENDSND1);
break;
case 39:
sound(VOL4ENDSND2);
break;
case 50:
FX_StopAllSounds();
break;
}
}
@ -183,16 +183,16 @@ void endanimvol43(long fr)
{
switch (fr)
{
case 1:
sound(BOSS4_DEADSPEECH);
break;
case 40:
sound(VOL4ENDSND1);
sound(DUKE_UNDERWATER);
break;
case 50:
sound(BIGBANG);
break;
case 1:
sound(BOSS4_DEADSPEECH);
break;
case 40:
sound(VOL4ENDSND1);
sound(DUKE_UNDERWATER);
break;
case 50:
sound(BIGBANG);
break;
}
}
@ -259,7 +259,8 @@ void playanm(char *fn,char t)
extern char restorepalette;
if (KB_KeyWaiting())
goto ENDOFANIMLOOP;
handleevents(); getpackets();
handleevents();
getpackets();
if (restorepalette == 1)
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
int32 ForceSetup = 1;
static char setupfilename[BMAX_PATH]={SETUPFILENAME};
static char setupfilename[BMAX_PATH]=
{
SETUPFILENAME
};
int32 scripthandle = -1;
static int32 setupread=0;
@ -185,15 +188,16 @@ int32 CONFIG_AnalogNameToNum(char * func)
char * CONFIG_AnalogNumToName(int32 func)
{
switch (func) {
case analog_turning:
return "analog_turning";
case analog_strafing:
return "analog_strafing";
case analog_moving:
return "analog_moving";
case analog_lookingupanddown:
return "analog_lookingupanddown";
switch (func)
{
case analog_turning:
return "analog_turning";
case analog_strafing:
return "analog_strafing";
case analog_moving:
return "analog_moving";
case analog_lookingupanddown:
return "analog_lookingupanddown";
}
return NULL;
@ -277,7 +281,8 @@ void CONFIG_SetDefaults(void)
// JBF 20031211
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]);
if (f == -1) continue;
KeyboardKeys[f][0] = KB_StringToScanCode(keydefaults[i+1]);
@ -288,7 +293,8 @@ void CONFIG_SetDefaults(void)
}
memset(MouseFunctions, -1, sizeof(MouseFunctions));
for (i=0; i<MAXMOUSEBUTTONS; i++) {
for (i=0; i<MAXMOUSEBUTTONS; i++)
{
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse);
if (i>=4) continue;
@ -297,7 +303,8 @@ void CONFIG_SetDefaults(void)
}
memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions));
for (i=0; i<MAXMOUSEAXES; i++) {
for (i=0; i<MAXMOUSEAXES; i++)
{
MouseAnalogueScale[i] = 65536;
CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse);
@ -312,7 +319,8 @@ void CONFIG_SetDefaults(void)
CONTROL_SetMouseSensitivity(DEFAULTMOUSESENSITIVITY);
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][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
CONTROL_MapButton(JoystickFunctions[i][0], i, 0, controldevice_joystick);
@ -320,7 +328,8 @@ void CONFIG_SetDefaults(void)
}
memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions));
for (i=0; i<MAXJOYAXES; i++) {
for (i=0; i<MAXJOYAXES; i++)
{
JoystickAnalogueScale[i] = 65536;
JoystickAnalogueDead[i] = 1000;
JoystickAnalogueSaturate[i] = 9500;
@ -415,12 +424,14 @@ void CONFIG_SetupMouse(void)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -429,17 +440,20 @@ void CONFIG_SetupMouse(void)
// map over the axes
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 (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -487,12 +501,14 @@ void CONFIG_SetupJoystick(void)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -501,17 +517,20 @@ void CONFIG_SetupJoystick(void)
// map over the axes
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 (CONFIG_AnalogNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
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 (CONFIG_FunctionNameToNum(temp) != -1 || temp[0] == 0)
JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp);
@ -559,12 +578,35 @@ void readsavenames(void)
{
fn[4] = i+'0';
if ((fil = Bfopen(fn,"rb")) == NULL) continue;
if (dfread(&j,sizeof(long),1,fil) != 1) { Bfclose(fil); continue; }
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; }
if (dfread(&j,sizeof(long),1,fil) != 1)
{
Bfclose(fil);
continue;
}
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);
}
}
@ -615,7 +657,8 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(scripthandle, "Screen Setup", "Shadows",&ud.shadows);
if (!NAM) {
if (!NAM)
{
SCRIPT_GetString(scripthandle, "Screen Setup","Password",&ud.pwlockout[0]);
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", "GLUseTextureCacheCompression", &glusetexcachecompression);
dummy = usemodels; SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseModels",&dummy); usemodels = dummy != 0;
dummy = usehightile; SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseHightile",&dummy); usehightile = dummy != 0;
dummy = usemodels;
SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseModels",&dummy);
usemodels = dummy != 0;
dummy = usehightile;
SCRIPT_GetNumber(scripthandle, "Screen Setup", "UseHightile",&dummy);
usehightile = dummy != 0;
#endif
SCRIPT_GetNumber(scripthandle, "Misc", "Executions",&ud.executions);
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", "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
if (!CommandWeaponChoice)
@ -787,7 +836,8 @@ void CONFIG_WriteSetup(void)
#endif
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_PutString(scripthandle, "Screen Setup", "Password",ud.pwlockout);
}
@ -813,7 +863,8 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(scripthandle, "Sound Setup", "VoiceToggle",VoiceToggle,false,false);
// JBF 20031211
for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++) {
for (dummy=0;dummy<NUMGAMEFUNCTIONS;dummy++)
{
SCRIPT_PutDoubleString(scripthandle, "KeyDefinitions", CONFIG_FunctionNumToName(dummy),
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);
}
for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++) {
for (dummy=0;dummy<MAXMOUSEBUTTONS;dummy++)
{
Bsprintf(buf,"MouseButton%ld",dummy);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][0]));
@ -833,7 +885,8 @@ void CONFIG_WriteSetup(void)
Bsprintf(buf,"MouseButtonClicked%ld",dummy);
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);
SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[dummy]));
@ -849,14 +902,16 @@ void CONFIG_WriteSetup(void)
dummy = CONTROL_GetMouseSensitivity();
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);
SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][0]));
Bsprintf(buf,"JoystickButtonClicked%ld",dummy);
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);
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 "grpscan.h"
struct grpfile grpfiles[numgrpfiles] = {
{ "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 Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL },
{ "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL },
};
struct grpfile grpfiles[numgrpfiles] =
{
{ "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 Mac Shareware Version", 0xC5F71561, 10444391, GAMEDUKE, NULL },
{ "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL },
{ "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL },
};
struct grpfile *foundgrps = NULL;
#define GRPCACHEFILE "grpfiles.cache"
static struct grpcache {
static struct grpcache
{
struct grpcache *next;
char name[BMAX_PATH+1];
int size;
int mtime;
int crcval;
} *grpcache = NULL, *usedgrpcache = NULL;
}
*grpcache = NULL, *usedgrpcache = NULL;
static int LoadGroupsCache(void)
{
@ -41,7 +45,8 @@ static int LoadGroupsCache(void)
script = scriptfile_fromfile(GRPCACHEFILE);
if (!script) return -1;
while (!scriptfile_eof(script)) {
while (!scriptfile_eof(script))
{
if (scriptfile_getstring(script, &fname)) break; // filename
if (scriptfile_getnumber(script, &fsize)) break; // filesize
if (scriptfile_getnumber(script, &fmtime)) break; // modification time
@ -65,7 +70,8 @@ static void FreeGroupsCache(void)
{
struct grpcache *fg;
while (grpcache) {
while (grpcache)
{
fg = grpcache->next;
free(grpcache);
grpcache = fg;
@ -86,16 +92,24 @@ int ScanGroups(void)
srch = klistpath("/", "*.grp", CACHE1D_FIND_FILE);
for (sidx = srch; sidx; sidx = sidx->next) {
for (fg = grpcache; fg; fg = fg->next) {
for (sidx = srch; sidx; sidx = sidx->next)
{
for (fg = grpcache; fg; fg = fg->next)
{
if (!Bstrcmp(fg->name, sidx->name)) break;
}
if (fg) {
if (fg)
{
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);
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->name = strdup(sidx->name);
grp->crcval = fg->crcval;
@ -125,10 +139,12 @@ int ScanGroups(void)
initprintf(" Checksumming %s...", sidx->name);
crc32init((unsigned long *)&crcval);
do {
do
{
b = read(fh, buf, sizeof(buf));
if (b > 0) crc32block((unsigned long *)&crcval, buf, b);
} while (b == sizeof(buf));
}
while (b == sizeof(buf));
crc32finish((unsigned long *)&crcval);
close(fh);
initprintf(" Done\n");
@ -153,11 +169,14 @@ int ScanGroups(void)
klistfree(srch);
FreeGroupsCache();
if (usedgrpcache) {
if (usedgrpcache)
{
FILE *fp;
fp = fopen(GRPCACHEFILE, "wt");
if (fp) {
for (fg = usedgrpcache; fg; fg=fgg) {
if (fp)
{
for (fg = usedgrpcache; fg; fg=fgg)
{
fgg = fg->next;
fprintf(fp, "\"%s\" %d %d %d\n", fg->name, fg->size, fg->mtime, fg->crcval);
free(fg);
@ -173,7 +192,8 @@ void FreeGroups(void)
{
struct grpfile *fg;
while (foundgrps) {
while (foundgrps)
{
fg = foundgrps->next;
free((char*)foundgrps->name);
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 i;
for (i = 0; i < parm->numparms; i++) {
for (i = 0; i < parm->numparms; i++)
{
if (i > 0) OSD_Printf(" ");
OSD_Printf("%s", parm->parms[i]);
}
@ -50,14 +51,17 @@ int osdcmd_changelevel(const osdfuncparm_t *parm)
int volume=0,level;
char *p;
if (!VOLUMEONE) {
if (!VOLUMEONE)
{
if (parm->numparms != 2) return OSDCMD_SHOWHELP;
volume = strtol(parm->parms[0], &p, 10) - 1;
if (p[0]) return OSDCMD_SHOWHELP;
level = strtol(parm->parms[1], &p, 10) - 1;
if (p[0]) return OSDCMD_SHOWHELP;
} else {
}
else
{
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
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 (level < 0) return OSDCMD_SHOWHELP;
if (!VOLUMEONE) {
if (volume > num_volumes) {
if (!VOLUMEONE)
{
if (volume > num_volumes)
{
OSD_Printf("changelevel: invalid volume number (range 1-%ld)\n",num_volumes);
return OSDCMD_OK;
}
}
if (volume == 0) {
if (level > 6) {
if (volume == 0)
{
if (level > 6)
{
OSD_Printf("changelevel: invalid volume 1 level number (range 1-7)\n");
return OSDCMD_OK;
}
} else {
if (level > 10) {
}
else
{
if (level > 10)
{
OSD_Printf("changelevel: invalid volume 2+ level number (range 1-11)\n");
return OSDCMD_SHOWHELP;
}
}
if (ps[myconnectindex].gm & MODE_GAME) {
if (ps[myconnectindex].gm & MODE_GAME)
{
// in-game behave like a cheat
osdcmd_cheatsinfo_stat.cheatnum = 2;
osdcmd_cheatsinfo_stat.volume = volume;
osdcmd_cheatsinfo_stat.level = level;
} else {
}
else
{
// out-of-game behave like a menu command
osdcmd_cheatsinfo_stat.cheatnum = -1;
@ -123,7 +137,8 @@ int osdcmd_map(const osdfuncparm_t *parm)
if (strchr(filename,'.') == 0)
strcat(filename,".map");
if ((i = kopen4load(filename,0)) < 0) {
if ((i = kopen4load(filename,0)) < 0)
{
OSD_Printf("map: file \"%s\" not found.\n", filename);
return OSDCMD_OK;
}
@ -131,12 +146,15 @@ int osdcmd_map(const osdfuncparm_t *parm)
strcpy(boardfilename, filename);
if (ps[myconnectindex].gm & MODE_GAME) {
if (ps[myconnectindex].gm & MODE_GAME)
{
// in-game behave like a cheat
osdcmd_cheatsinfo_stat.cheatnum = 2;
osdcmd_cheatsinfo_stat.volume = 0;
osdcmd_cheatsinfo_stat.level = 7;
} else {
}
else
{
// out-of-game behave like a menu command
osdcmd_cheatsinfo_stat.cheatnum = -1;
@ -159,9 +177,12 @@ int osdcmd_map(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;
} else {
}
else
{
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)
{
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) {
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
osdcmd_cheatsinfo_stat.cheatnum = 20;
} else {
}
else
{
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 ((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]);
return OSDCMD_OK;
}
@ -195,10 +220,12 @@ int osdcmd_fileinfo(const osdfuncparm_t *parm)
length = kfilelength(i);
crc32init(&crc);
do {
do
{
j = kread(i,buf,256);
crc32block(&crc,buf,j);
} while (j == 256);
}
while (j == 256);
crc32finish(&crc);
kclose(i);
@ -228,30 +255,34 @@ static int osdcmd_vidmode(const osdfuncparm_t *parm)
newheight = ScreenHeight, newfs = ScreenMode;
if (parm->numparms < 1 || parm->numparms > 4) return OSDCMD_SHOWHELP;
switch (parm->numparms) {
case 1: // bpp switch
newbpp = Batol(parm->parms[0]);
break;
case 2: // res switch
newwidth = Batol(parm->parms[0]);
newheight = Batol(parm->parms[1]);
break;
case 3: // res & bpp switch
case 4:
newwidth = Batol(parm->parms[0]);
newheight = Batol(parm->parms[1]);
newbpp = Batol(parm->parms[2]);
if (parm->numparms == 4)
newfs = (Batol(parm->parms[3]) != 0);
break;
switch (parm->numparms)
{
case 1: // bpp switch
newbpp = Batol(parm->parms[0]);
break;
case 2: // res switch
newwidth = Batol(parm->parms[0]);
newheight = Batol(parm->parms[1]);
break;
case 3: // res & bpp switch
case 4:
newwidth = Batol(parm->parms[0]);
newheight = Batol(parm->parms[1]);
newbpp = Batol(parm->parms[2]);
if (parm->numparms == 4)
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");
if (setgamemode(ScreenMode, ScreenWidth, ScreenHeight, ScreenBPP))
gameexit("vidmode: Reset failed!\n");
}
ScreenBPP = newbpp; ScreenWidth = newwidth; ScreenHeight = newheight;
ScreenBPP = newbpp;
ScreenWidth = newwidth;
ScreenHeight = newheight;
ScreenMode = newfs;
onvideomodechange(ScreenBPP>8);
vscrn();
@ -260,10 +291,12 @@ static int osdcmd_vidmode(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);
return OSDCMD_SHOWHELP;
} else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
}
else if (parm->numparms != 1) return OSDCMD_SHOWHELP;
setstatusbarscale(Batol(parm->parms[0]));
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)
{
if (parm->numparms == 0) {
if (parm->numparms == 0)
{
OSD_Printf("\"cl_statusbarmode\" is \"%d\"\n", ud.statusbarmode);
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]);
vscrn();
@ -291,61 +326,76 @@ static int osdcmd_spawn(const osdfuncparm_t *parm)
short ang=0;
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");
return OSDCMD_OK;
}
switch (parm->numparms) {
case 7: // x,y,z
x = Batol(parm->parms[4]);
y = Batol(parm->parms[5]);
z = Batol(parm->parms[6]);
set |= 8;
case 4: // ang
ang = Batol(parm->parms[3]) & 2047; set |= 4;
case 3: // cstat
cstat = (unsigned short)Batol(parm->parms[2]); set |= 2;
case 2: // pal
pal = (unsigned char)Batol(parm->parms[1]); set |= 1;
case 1: // tile number
if (isdigit(parm->parms[0][0])) {
picnum = (unsigned short)Batol(parm->parms[0]);
} else {
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;
switch (parm->numparms)
{
case 7: // x,y,z
x = Batol(parm->parms[4]);
y = Batol(parm->parms[5]);
z = Batol(parm->parms[6]);
set |= 8;
case 4: // ang
ang = Batol(parm->parms[3]) & 2047;
set |= 4;
case 3: // cstat
cstat = (unsigned short)Batol(parm->parms[2]);
set |= 2;
case 2: // pal
pal = (unsigned char)Batol(parm->parms[1]);
set |= 1;
case 1: // tile number
if (isdigit(parm->parms[0][0]))
{
picnum = (unsigned short)Batol(parm->parms[0]);
}
if (i==labelcnt) {
OSD_Printf("spawn: Invalid tile label given\n");
else
{
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;
}
}
if (picnum >= MAXTILES) {
OSD_Printf("spawn: Invalid tile number\n");
return OSDCMD_OK;
}
break;
default:
return OSDCMD_SHOWHELP;
break;
default:
return OSDCMD_SHOWHELP;
}
idx = spawn(ps[myconnectindex].i, (short)picnum);
if (set & 1) sprite[idx].pal = (char)pal;
if (set & 2) sprite[idx].cstat = (short)cstat;
if (set & 4) sprite[idx].ang = ang;
if (set & 8) {
if (setsprite(idx, x,y,z) < 0) {
if (set & 8)
{
if (setsprite(idx, x,y,z) < 0)
{
OSD_Printf("spawn: Sprite can't be spawned into null space\n");
deletesprite(idx);
}
@ -402,10 +452,13 @@ int osdcmd_initgroupfile(const osdfuncparm_t *parm)
int osdcmd_cmenu(const osdfuncparm_t *parm)
{
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if (numplayers > 1) {
if (numplayers > 1)
{
OSD_Printf("cmenu: disallowed in multiplayer\n");
return OSDCMD_OK;
} else {
}
else
{
cmenu(Batol(parm->parms[0]));
}
@ -420,7 +473,8 @@ int osdcmd_exec(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
Bstrcpy(fn,parm->parms[0]);
if (load_script(fn)) {
if (load_script(fn))
{
OSD_Printf("exec: file \"%s\" not found.\n", fn);
return OSDCMD_OK;
}
@ -434,7 +488,8 @@ enum cvartypes {
CVAR_STRING
};
struct cvarmappings {
struct cvarmappings
{
char *name;
char *helpstr;
void *var;
@ -442,7 +497,8 @@ struct cvarmappings {
int extra; // for string, is the length
int min;
int max;
} cvar[] =
}
cvar[] =
{
{ "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 },
#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 },
// 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 },
@ -484,48 +539,59 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
int showval = (parm->numparms == 0);
unsigned int 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) {
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)
{
// sound the alarm
OSD_Printf("Cvar \"%s\" locked in multiplayer.\n",cvar[i].name);
return OSDCMD_OK;
} else
switch (cvar[i].type&0x7f) {
case CVAR_INT:
case CVAR_UNSIGNEDINT:
case CVAR_BOOL:
}
else
switch (cvar[i].type&0x7f)
{
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;
}
case CVAR_INT:
case CVAR_UNSIGNEDINT:
case CVAR_BOOL:
{
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]);
if (cvar[i].type == CVAR_BOOL) val = val != 0;
val = atoi(parm->parms[0]);
if (cvar[i].type == CVAR_BOOL) val = val != 0;
if (val < cvar[i].min || val > cvar[i].max) {
OSD_Printf("%s value out of range\n",cvar[i].name);
return OSDCMD_OK;
if (val < cvar[i].min || val > cvar[i].max)
{
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;
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)
updatenames();
@ -537,7 +603,8 @@ int osdcmd_cvar_set(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());
return OSDCMD_SHOWHELP;
}
@ -548,7 +615,8 @@ int osdcmd_sensitivity(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);
return OSDCMD_SHOWHELP;
}
@ -562,44 +630,57 @@ int osdcmd_give(const osdfuncparm_t *parm)
{
int i;
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) {
if (ps[myconnectindex].dead_flag != 0) {
if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME)
{
if (ps[myconnectindex].dead_flag != 0)
{
OSD_Printf("give: Cannot give while dead.\n");
return OSDCMD_OK;
}
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if (!Bstrcasecmp(parm->parms[0], "all")) {
if (!Bstrcasecmp(parm->parms[0], "all"))
{
osdcmd_cheatsinfo_stat.cheatnum = 1;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "health")) {
else if (!Bstrcasecmp(parm->parms[0], "health"))
{
sprite[ps[myconnectindex].i].extra = 200;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "weapons")) {
else if (!Bstrcasecmp(parm->parms[0], "weapons"))
{
osdcmd_cheatsinfo_stat.cheatnum = 21;
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++)
{
addammo(i,&ps[myconnectindex],max_ammo_amount[i]);
}
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "armor")) {
else if (!Bstrcasecmp(parm->parms[0], "armor"))
{
ps[myconnectindex].shield_amount = 100;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "keys")) {
else if (!Bstrcasecmp(parm->parms[0], "keys"))
{
osdcmd_cheatsinfo_stat.cheatnum = 23;
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->parms[0], "inventory")) {
else if (!Bstrcasecmp(parm->parms[0], "inventory"))
{
osdcmd_cheatsinfo_stat.cheatnum = 22;
return OSDCMD_OK;
}
} else {
}
else
{
OSD_Printf("give: Not in a single-player game.\n");
return OSDCMD_OK;
}
@ -610,14 +691,17 @@ void onvideomodechange(int newmode)
{
char *pal;
if (newmode) {
if (newmode)
{
if (ps[screenpeek].palette == palette ||
ps[screenpeek].palette == waterpal ||
ps[screenpeek].palette == slimepal)
pal = palette;
else
pal = ps[screenpeek].palette;
} else {
}
else
{
pal = ps[screenpeek].palette;
}
@ -628,17 +712,27 @@ void onvideomodechange(int newmode)
int osdcmd_usemousejoy(const osdfuncparm_t *parm)
{
int showval = (parm->numparms < 1);
if (!Bstrcasecmp(parm->name, "usemouse")) {
if (showval) { OSD_Printf("usemouse is %d\n", UseMouse); }
else {
if (!Bstrcasecmp(parm->name, "usemouse"))
{
if (showval)
{
OSD_Printf("usemouse is %d\n", UseMouse);
}
else
{
UseMouse = (atoi(parm->parms[0]) != 0);
CONTROL_MouseEnabled = (UseMouse && CONTROL_MousePresent);
}
return OSDCMD_OK;
}
else if (!Bstrcasecmp(parm->name, "usejoystick")) {
if (showval) { OSD_Printf("usejoystick is %d\n", UseJoystick); }
else {
else if (!Bstrcasecmp(parm->name, "usejoystick"))
{
if (showval)
{
OSD_Printf("usejoystick is %d\n", UseJoystick);
}
else
{
UseJoystick = (atoi(parm->parms[0]) != 0);
CONTROL_JoystickEnabled = (UseJoystick && CONTROL_JoyPresent);
}
@ -658,7 +752,8 @@ int osdcmd_mpmap(const osdfuncparm_t *parm)
if (strchr(filename,'.') == 0)
strcat(filename,".map");
if ((i = kopen4load(filename,0)) < 0) {
if ((i = kopen4load(filename,0)) < 0)
{
OSD_Printf("map: file \"%s\" not found.\n", filename);
return OSDCMD_OK;
}
@ -700,13 +795,17 @@ int registerosdcommands(void)
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);
}
if (VOLUMEONE) {
if (VOLUMEONE)
{
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("map","map <mapfile>: loads the given user map", osdcmd_map);
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;
for (x = (x<<3)+x; len>0; len--, ch++, x++) {
if (*ch == 32) { x+=5; continue; }
for (x = (x<<3)+x; len>0; len--, ch++, x++)
{
if (*ch == 32)
{
x+=5;
continue;
}
ac = *ch-'!'+STARTALPHANUM;
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 daydim, bits;
if (getrendermode() < 3) bits = BITS; else bits = BITSTL;
if (getrendermode() < 3) bits = BITS;
else bits = BITSTL;
daydim = r<<3;
xsiz = tilesizx[BGTILE]; tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE]; ty2 = daydim/ysiz;
xsiz = tilesizx[BGTILE];
tx2 = xdim/xsiz;
ysiz = tilesizy[BGTILE];
ty2 = daydim/ysiz;
for (x=0;x<=tx2;x++)
for (y=0;y<=ty2;y++)
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];
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)
{
if ((picanm[tilenume]&63) > 0) {
if ((picanm[tilenume]&63) > 0)
{
int i,j;
if ((picanm[tilenume]&192)==192) {
if ((picanm[tilenume]&192)==192)
{
i = tilenume - (picanm[tilenume]&63);
j = tilenume;
} else {
}
else
{
i = tilenume;
j = tilenume + (picanm[tilenume]&63);
}
for (;i<=j;i++) {
for (;i<=j;i++)
{
if (!(gotpic[i>>3] & pow2char[i&7])) precachecount++;
gotpic[i>>3] |= pow2char[i&7];
precachehightile[type][i>>3] |= pow2char[i&7];
}
} else {
}
else
{
if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) precachecount++;
gotpic[tilenume>>3] |= pow2char[tilenume&7];
precachehightile[type][tilenume>>3] |= pow2char[tilenume&7];
@ -72,115 +79,124 @@ void cachespritenum(short i)
switch (dynamictostatic[PN])
{
case HYDRENT__STATIC:
tloadtile(BROKEFIREHYDRENT,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case TOILET__STATIC:
tloadtile(TOILETBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case STALL__STATIC:
tloadtile(STALLBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case RUBBERCAN__STATIC:
maxc = 2;
break;
case TOILETWATER__STATIC:
maxc = 4;
break;
case FEMPIC1__STATIC:
maxc = 44;
break;
case LIZTROOP__STATIC:
case LIZTROOPRUNNING__STATIC:
case LIZTROOPSHOOT__STATIC:
case LIZTROOPJETPACK__STATIC:
case LIZTROOPONTOILET__STATIC:
case LIZTROOPDUCKING__STATIC:
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1);
maxc = 0;
break;
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)
{
case HYDRENT__STATIC:
tloadtile(BROKEFIREHYDRENT,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case TOILET__STATIC:
tloadtile(TOILETBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case STALL__STATIC:
tloadtile(STALLBROKE,1);
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
break;
case RUBBERCAN__STATIC:
maxc = 2;
break;
case TOILETWATER__STATIC:
maxc = 4;
break;
case FEMPIC1__STATIC:
maxc = 44;
break;
case LIZTROOP__STATIC:
case LIZTROOPRUNNING__STATIC:
case LIZTROOPSHOOT__STATIC:
case LIZTROOPJETPACK__STATIC:
case LIZTROOPONTOILET__STATIC:
case LIZTROOPDUCKING__STATIC:
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
for (j=HEADJIB1;j<LEGJIB1+3;j++) tloadtile(j,1);
maxc = 0;
break;
case WOODENHORSE__STATIC:
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;
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;
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++;
if ((j&7) == 0)
{ handleevents(); getpackets(); }
{
handleevents();
getpackets();
}
getsound(i);
}
}
@ -298,7 +317,8 @@ void cacheit(void)
{
tloadtile(wall[i].picnum, 0);
if (wall[i].overpicnum >= 0) {
if (wall[i].overpicnum >= 0)
{
tloadtile(wall[i].overpicnum, 0);
}
}
@ -325,17 +345,21 @@ void cacheit(void)
tc = totalclock;
j = 0;
for (i=0;i<MAXTILES;i++) {
if (!(i&7) && !gotpic[i>>3]) {
for (i=0;i<MAXTILES;i++)
{
if (!(i&7) && !gotpic[i>>3])
{
i+=7;
continue;
}
if (gotpic[i>>3] & pow2char[i&7]) {
if (gotpic[i>>3] & pow2char[i&7])
{
if (waloff[i] == 0)
loadtile((short)i);
#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])
for (k=0; k<MAXPALOOKUPS; k++)
polymost_precache(i,k,0);
@ -347,10 +371,16 @@ void cacheit(void)
#endif
j++;
pc++;
} else continue;
}
else continue;
if ((j&7) == 0) { handleevents(); getpackets(); }
if (totalclock - tc > TICRATE/4) {
if ((j&7) == 0)
{
handleevents();
getpackets();
}
if (totalclock - tc > TICRATE/4)
{
sprintf(tempbuf,"Loading textures ... %ld%%\n",min(100,100*pc/precachecount));
dofrontscreens(tempbuf);
tc = totalclock;
@ -369,7 +399,9 @@ void xyzmirror(short i,short wn)
setviewtotile(wn,tilesizy[wn],tilesizx[wn]);
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();
setviewback();
@ -391,7 +423,8 @@ void vscrn(void)
x1 = scale(ss,xdim,160);
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)
{
j = 0;
@ -440,7 +473,8 @@ void pickrandomspot(short snum)
break;
}
}
} else i = TRAND%numplayersprites;
}
else i = TRAND%numplayersprites;
}
else i = snum;
@ -596,9 +630,12 @@ void resetinventory(short snum)
p->inven_icon = 0;
p->boot_amount = 0;
p->scuba_on = 0;p->scuba_amount = 0;
p->heat_amount = 0;p->heat_on = 0;
p->jetpack_on = 0;p->jetpack_amount = 0;
p->scuba_on = 0;
p->scuba_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->holoduke_on = -1;
p->holoduke_amount = 0;
@ -682,20 +719,32 @@ void setupbackdrop(short sky)
switch (dynamictostatic[sky])
{
case CLOUDYOCEAN__STATIC:
parallaxyscale = 65536L;
break;
case MOONSKY1__STATIC :
pskyoff[6]=1; pskyoff[1]=2; pskyoff[4]=2; pskyoff[2]=3;
break;
case BIGORBIT1__STATIC: // orbit
pskyoff[5]=1; pskyoff[6]=2; pskyoff[7]=3; 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;
case CLOUDYOCEAN__STATIC:
parallaxyscale = 65536L;
break;
case MOONSKY1__STATIC :
pskyoff[6]=1;
pskyoff[1]=2;
pskyoff[4]=2;
pskyoff[2]=3;
break;
case BIGORBIT1__STATIC: // orbit
pskyoff[5]=1;
pskyoff[6]=2;
pskyoff[7]=3;
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;
@ -721,11 +770,11 @@ void prelevel(char g)
switch (sector[i].lotag)
{
case 20:
case 22:
if (sector[i].floorz > sector[i].ceilingz)
sector[i].lotag |= 32768;
continue;
case 20:
case 22:
if (sector[i].floorz > sector[i].ceilingz)
sector[i].lotag |= 32768;
continue;
}
if (sector[i].ceilingstat&1)
@ -772,37 +821,37 @@ void prelevel(char g)
}
else switch (dynamictostatic[PN])
{
case GPSPEED__STATIC:
sector[SECT].extra = SLT;
deletesprite(i);
break;
case GPSPEED__STATIC:
sector[SECT].extra = SLT;
deletesprite(i);
break;
case CYCLER__STATIC:
if (numcyclers >= MAXCYCLERS)
{
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
gameexit(tempbuf);
}
cyclers[numcyclers][0] = SECT;
cyclers[numcyclers][1] = SLT;
cyclers[numcyclers][2] = SS;
cyclers[numcyclers][3] = sector[SECT].floorshade;
cyclers[numcyclers][4] = SHT;
cyclers[numcyclers][5] = (SA == 1536);
numcyclers++;
deletesprite(i);
break;
case CYCLER__STATIC:
if (numcyclers >= MAXCYCLERS)
{
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
gameexit(tempbuf);
}
cyclers[numcyclers][0] = SECT;
cyclers[numcyclers][1] = SLT;
cyclers[numcyclers][2] = SS;
cyclers[numcyclers][3] = sector[SECT].floorshade;
cyclers[numcyclers][4] = SHT;
cyclers[numcyclers][5] = (SA == 1536);
numcyclers++;
deletesprite(i);
break;
case SECTOREFFECTOR__STATIC:
case ACTIVATOR__STATIC:
case TOUCHPLATE__STATIC:
case ACTIVATORLOCKED__STATIC:
case MUSICANDSFX__STATIC:
case LOCATORS__STATIC:
case MASTERSWITCH__STATIC:
case RESPAWN__STATIC:
sprite[i].cstat = 0;
break;
case SECTOREFFECTOR__STATIC:
case ACTIVATOR__STATIC:
case TOUCHPLATE__STATIC:
case ACTIVATORLOCKED__STATIC:
case MUSICANDSFX__STATIC:
case LOCATORS__STATIC:
case MASTERSWITCH__STATIC:
case RESPAWN__STATIC:
sprite[i].cstat = 0;
break;
}
i = nexti;
}
@ -831,39 +880,39 @@ void prelevel(char g)
{
switch (dynamictostatic[PN-1])
{
case DIPSWITCH__STATIC:
case DIPSWITCH2__STATIC:
case PULLSWITCH__STATIC:
case HANDSWITCH__STATIC:
case SLOTDOOR__STATIC:
case LIGHTSWITCH__STATIC:
case SPACELIGHTSWITCH__STATIC:
case SPACEDOORSWITCH__STATIC:
case FRANKENSTINESWITCH__STATIC:
case LIGHTSWITCH2__STATIC:
case POWERSWITCH1__STATIC:
case LOCKSWITCH1__STATIC:
case POWERSWITCH2__STATIC:
for (j=0;j<lotaglist;j++)
if (SLT == lotags[j])
break;
case DIPSWITCH__STATIC:
case DIPSWITCH2__STATIC:
case PULLSWITCH__STATIC:
case HANDSWITCH__STATIC:
case SLOTDOOR__STATIC:
case LIGHTSWITCH__STATIC:
case SPACELIGHTSWITCH__STATIC:
case SPACEDOORSWITCH__STATIC:
case FRANKENSTINESWITCH__STATIC:
case LIGHTSWITCH2__STATIC:
case POWERSWITCH1__STATIC:
case LOCKSWITCH1__STATIC:
case POWERSWITCH2__STATIC:
for (j=0;j<lotaglist;j++)
if (SLT == lotags[j])
break;
if (j == lotaglist)
{
lotags[lotaglist] = SLT;
lotaglist++;
if (lotaglist > 64)
gameexit("\nToo many switches (64 max).");
j = headspritestat[3];
while (j >= 0)
if (j == lotaglist)
{
if (sprite[j].lotag == 12 && sprite[j].hitag == SLT)
hittype[j].temp_data[0] = 1;
j = nextspritestat[j];
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)
hittype[j].temp_data[0] = 1;
j = nextspritestat[j];
}
}
}
break;
break;
}
i = nextspritestat[i];
}
@ -901,110 +950,111 @@ void prelevel(char g)
animwall[numanimwalls].tag = 0;
animwall[numanimwalls].wallnum = 0;
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;
}
switch (dynamictostatic[switchpicnum])
{
case FANSHADOW__STATIC:
case FANSPRITE__STATIC:
wall->cstat |= 65;
animwall[numanimwalls].wallnum = i;
numanimwalls++;
break;
case FANSHADOW__STATIC:
case FANSPRITE__STATIC:
wall->cstat |= 65;
animwall[numanimwalls].wallnum = i;
numanimwalls++;
break;
case W_FORCEFIELD__STATIC:
if (wal->overpicnum==W_FORCEFIELD__STATIC)
for (j=0;j<3;j++)
tloadtile(W_FORCEFIELD+j, 0);
if (wal->shade > 31)
wal->cstat = 0;
else wal->cstat |= 85+256;
case W_FORCEFIELD__STATIC:
if (wal->overpicnum==W_FORCEFIELD__STATIC)
for (j=0;j<3;j++)
tloadtile(W_FORCEFIELD+j, 0);
if (wal->shade > 31)
wal->cstat = 0;
else wal->cstat |= 85+256;
if (wal->lotag && wal->nextwall >= 0)
wall[wal->nextwall].lotag =
wal->lotag;
if (wal->lotag && wal->nextwall >= 0)
wall[wal->nextwall].lotag =
wal->lotag;
case BIGFORCE__STATIC:
case BIGFORCE__STATIC:
animwall[numanimwalls].wallnum = i;
numanimwalls++;
animwall[numanimwalls].wallnum = i;
numanimwalls++;
continue;
continue;
}
wal->extra = -1;
switch (dynamictostatic[wal->picnum])
{
case WATERTILE2__STATIC:
for (j=0;j<3;j++)
tloadtile(wal->picnum+j, 0);
break;
case WATERTILE2__STATIC:
for (j=0;j<3;j++)
tloadtile(wal->picnum+j, 0);
break;
case TECHLIGHT2__STATIC:
case TECHLIGHT4__STATIC:
tloadtile(wal->picnum, 0);
break;
case W_TECHWALL1__STATIC:
case W_TECHWALL2__STATIC:
case W_TECHWALL3__STATIC:
case W_TECHWALL4__STATIC:
animwall[numanimwalls].wallnum = i;
// animwall[numanimwalls].tag = -1;
numanimwalls++;
break;
case SCREENBREAK6__STATIC:
case SCREENBREAK7__STATIC:
case SCREENBREAK8__STATIC:
for (j=SCREENBREAK6;j<SCREENBREAK9;j++)
tloadtile(j, 0);
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = -1;
numanimwalls++;
break;
case TECHLIGHT2__STATIC:
case TECHLIGHT4__STATIC:
tloadtile(wal->picnum, 0);
break;
case W_TECHWALL1__STATIC:
case W_TECHWALL2__STATIC:
case W_TECHWALL3__STATIC:
case W_TECHWALL4__STATIC:
animwall[numanimwalls].wallnum = i;
// animwall[numanimwalls].tag = -1;
numanimwalls++;
break;
case SCREENBREAK6__STATIC:
case SCREENBREAK7__STATIC:
case SCREENBREAK8__STATIC:
for (j=SCREENBREAK6;j<SCREENBREAK9;j++)
tloadtile(j, 0);
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = -1;
numanimwalls++;
break;
case FEMPIC1__STATIC:
case FEMPIC2__STATIC:
case FEMPIC3__STATIC:
case FEMPIC1__STATIC:
case FEMPIC2__STATIC:
case FEMPIC3__STATIC:
wal->extra = wal->picnum;
animwall[numanimwalls].tag = -1;
if (ud.lockout)
{
if (wal->picnum == FEMPIC1)
wal->picnum = BLANKSCREEN;
else wal->picnum = SCREENBREAK6;
}
wal->extra = wal->picnum;
animwall[numanimwalls].tag = -1;
if (ud.lockout)
{
if (wal->picnum == FEMPIC1)
wal->picnum = BLANKSCREEN;
else wal->picnum = SCREENBREAK6;
}
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum;
numanimwalls++;
break;
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum;
numanimwalls++;
break;
case SCREENBREAK1__STATIC:
case SCREENBREAK2__STATIC:
case SCREENBREAK3__STATIC:
case SCREENBREAK4__STATIC:
case SCREENBREAK5__STATIC:
case SCREENBREAK1__STATIC:
case SCREENBREAK2__STATIC:
case SCREENBREAK3__STATIC:
case SCREENBREAK4__STATIC:
case SCREENBREAK5__STATIC:
case SCREENBREAK9__STATIC:
case SCREENBREAK10__STATIC:
case SCREENBREAK11__STATIC:
case SCREENBREAK12__STATIC:
case SCREENBREAK13__STATIC:
case SCREENBREAK14__STATIC:
case SCREENBREAK15__STATIC:
case SCREENBREAK16__STATIC:
case SCREENBREAK17__STATIC:
case SCREENBREAK18__STATIC:
case SCREENBREAK19__STATIC:
case SCREENBREAK9__STATIC:
case SCREENBREAK10__STATIC:
case SCREENBREAK11__STATIC:
case SCREENBREAK12__STATIC:
case SCREENBREAK13__STATIC:
case SCREENBREAK14__STATIC:
case SCREENBREAK15__STATIC:
case SCREENBREAK16__STATIC:
case SCREENBREAK17__STATIC:
case SCREENBREAK18__STATIC:
case SCREENBREAK19__STATIC:
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum;
numanimwalls++;
break;
animwall[numanimwalls].wallnum = i;
animwall[numanimwalls].tag = wal->picnum;
numanimwalls++;
break;
}
}
@ -1027,8 +1077,16 @@ void newgame(char vn,char ln,char sk)
short i;
if (globalskillsound >= 0 && FXDevice >= 0 && SoundToggle)
while (issoundplaying(-1,globalskillsound)) { handleevents(); getpackets(); }
else { handleevents(); getpackets(); }
while (issoundplaying(-1,globalskillsound))
{
handleevents();
getpackets();
}
else
{
handleevents();
getpackets();
}
globalskillsound = -1;
waitforeverybody();
@ -1238,8 +1296,10 @@ void resetpspritevars(char g)
{
int k;
for (k=0;k<MAXPLAYERS;k++) {
if (which_palookup == ps[k].palookup) {
for (k=0;k<MAXPLAYERS;k++)
{
if (which_palookup == ps[k].palookup)
{
which_palookup++;
if (which_palookup >= 17)
which_palookup = 9;
@ -1260,10 +1320,12 @@ void resetpspritevars(char g)
{
switch (ud.pteam[j])
{
case 0:
k = 3; break;
case 1:
k = 21; break;
case 0:
k = 3;
break;
case 1:
k = 21;
break;
}
ps[j].team = ud.pteam[j];
}
@ -1378,7 +1440,11 @@ void waitforeverybody()
for (i=connecthead;i>=0;i=connectpoint2[i])
{
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;
@ -1391,7 +1457,8 @@ void dofrontscreens(char *statustext)
if (ud.recstat != 2)
{
if (!statustext) {
if (!statustext)
{
//ps[myconnectindex].palette = palette;
setgamepalette(&ps[myconnectindex], palette, 1); // JBF 20040308
fadepal(0,0,0, 0,64,7);
@ -1548,7 +1615,8 @@ int enterlevel(char g)
vscrn();
ud.screen_size = i;
if (!VOLUMEONE) {
if (!VOLUMEONE)
{
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);
//gameexit(tempbuf);
return 1;
} else {
}
else
{
char *p;
strcpy(levname, boardfilename);
p = Bstrrchr(levname,'.');
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);
}
}
@ -1571,16 +1647,26 @@ int enterlevel(char g)
initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]);
//gameexit(tempbuf);
return 1;
} else {
}
else
{
char *p;
strcpy(levname, level_file_names[(ud.volume_number*11)+ud.level_number]);
p = Bstrrchr(levname,'.');
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);
}
} else {
}
else
{
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);
@ -1592,11 +1678,19 @@ int enterlevel(char g)
initprintf("Map %s not found!\n",level_file_names[(ud.volume_number*11)+ud.level_number]);
//gameexit(tempbuf);
return 1;
} else {
}
else
{
char *p;
p = Bstrrchr(levname,'.');
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);
}
}
@ -1636,23 +1730,24 @@ int enterlevel(char g)
if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART)
opendemowrite();
if (VOLUMEONE) {
if (VOLUMEONE)
{
if (ud.level_number == 0 && ud.recstat != 2) FTA(40,&ps[myconnectindex]);
}
for (i=connecthead;i>=0;i=connectpoint2[i])
switch (dynamictostatic[sector[sprite[ps[i].i].sectnum].floorpicnum])
{
case HURTRAIL__STATIC:
case FLOORSLIME__STATIC:
case FLOORPLASMA__STATIC:
resetweapons(i);
resetinventory(i);
ps[i].gotweapon[PISTOL_WEAPON] = 0;
ps[i].ammo_amount[PISTOL_WEAPON] = 0;
ps[i].curr_weapon = KNEE_WEAPON;
ps[i].kickback_pic = 0;
break;
case HURTRAIL__STATIC:
case FLOORSLIME__STATIC:
case FLOORPLASMA__STATIC:
resetweapons(i);
resetinventory(i);
ps[i].gotweapon[PISTOL_WEAPON] = 0;
ps[i].ammo_amount[PISTOL_WEAPON] = 0;
ps[i].curr_weapon = KNEE_WEAPON;
ps[i].kickback_pic = 0;
break;
}
//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
handle = kopen4load(filename, 0);
if (handle < 0) {
if (handle < 0)
{
initprintf("RTS file %s was not found\n",filename);
return -1;
}
@ -82,7 +83,8 @@ int32 RTS_AddFile(char *filename)
// WAD file
initprintf(" Adding %s.\n",filename);
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);
kclose(handle);
return -1;
@ -91,7 +93,8 @@ int32 RTS_AddFile(char *filename)
header.infotableofs = IntelLong(header.infotableofs);
length = header.numlumps*sizeof(filelump_t);
fileinfo = fileinfoo = (filelump_t*)malloc(length);
if (!fileinfo) {
if (!fileinfo)
{
initprintf("RTS file could not allocate header info\n");
kclose(handle);
return -1;
@ -103,7 +106,8 @@ int32 RTS_AddFile(char *filename)
// Fill in lumpinfo
//
lump_p = realloc(lumpinfo, (numlumps + header.numlumps)*sizeof(lumpinfo_t));
if (!lump_p) {
if (!lump_p)
{
kclose(handle);
return -1;
}

View file

@ -41,7 +41,8 @@ int loadpheader(char spot,struct savehead *saveh)
// AddLog(g_szBuf);
if (kdfread(&bv,4,1,fil) != 1) goto corrupt;
if (bv != BYTEVERSION) {
if (bv != BYTEVERSION)
{
FTA(114,&ps[myconnectindex]);
kclose(fil);
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 (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;
invalidatetile(TILE_LOADSHOT,0,255);
@ -133,7 +135,8 @@ int loadplayer(signed char spot)
ready2send = 1;
FTA(124,&ps[myconnectindex]);
return 1;
} else ud.multimode = nump;
}
else ud.multimode = nump;
if (numplayers > 1)
{
@ -151,9 +154,12 @@ int loadplayer(signed char spot)
clearsoundlocks();
MUSIC_StopSong();
if (numplayers > 1) {
if (numplayers > 1)
{
if (kdfread(&buf,19,1,fil) != 1) goto corrupt;
} else {
}
else
{
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
walock[TILE_LOADSHOT] = 1;
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;
invalidatetile(TILE_LOADSHOT,0,255);
@ -372,13 +379,13 @@ int loadplayer(signed char spot)
for (x=0;x<numanimwalls;x++)
switch (dynamictostatic[wall[animwall[x].wallnum].picnum])
{
case FEMPIC1__STATIC:
wall[animwall[x].wallnum].picnum = BLANKSCREEN;
break;
case FEMPIC2__STATIC:
case FEMPIC3__STATIC:
wall[animwall[x].wallnum].picnum = SCREENBREAK6;
break;
case FEMPIC1__STATIC:
wall[animwall[x].wallnum].picnum = BLANKSCREEN;
break;
case FEMPIC2__STATIC:
case FEMPIC3__STATIC:
wall[animwall[x].wallnum].picnum = SCREENBREAK6;
break;
}
}
@ -390,31 +397,31 @@ int loadplayer(signed char spot)
{
switch (sprite[k].lotag)
{
case 31:
setinterpolation(&sector[sprite[k].sectnum].floorz);
break;
case 32:
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 25:
setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 17:
setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 0:
case 5:
case 6:
case 11:
case 14:
case 15:
case 16:
case 26:
case 30:
setsectinterpolate(k);
break;
case 31:
setinterpolation(&sector[sprite[k].sectnum].floorz);
break;
case 32:
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 25:
setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 17:
setinterpolation(&sector[sprite[k].sectnum].floorz);
setinterpolation(&sector[sprite[k].sectnum].ceilingz);
break;
case 0:
case 5:
case 6:
case 11:
case 14:
case 15:
case 16:
case 26:
case 30:
setsectinterpolate(k);
break;
}
k = nextspritestat[k];
@ -503,7 +510,8 @@ int saveplayer(signed char spot)
dfwrite(&ud.level_number,sizeof(ud.level_number),1,fil);
dfwrite(&ud.player_skill,sizeof(ud.player_skill),1,fil);
dfwrite(&boardfilename[0],BMAX_PATH,1,fil);
if (!waloff[TILE_SAVESHOT]) {
if (!waloff[TILE_SAVESHOT])
{
walock[TILE_SAVESHOT] = 254;
allocache((long *)&waloff[TILE_SAVESHOT],200*320,&walock[TILE_SAVESHOT]);
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;
status = FX_Init(FXDevice, NumVoices, NumChannels, NumBits, MixRate);
if (status == FX_Ok) {
if (status == FX_Ok)
{
FX_SetVolume(FXVolume);
if (ReverseStereo == 1) {
if (ReverseStereo == 1)
{
FX_SetReverseStereo(!FX_GetReverseStereo());
}
status = FX_SetCallBack(testcallback);
}
if (status != FX_Ok) {
if (status != FX_Ok)
{
sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
gameexit(tempbuf);
}
@ -81,7 +84,8 @@ void SoundShutdown(void)
return;
status = FX_Shutdown();
if (status != FX_Ok) {
if (status != FX_Ok)
{
sprintf(tempbuf, "Sound shutdown error: %s", FX_ErrorString(FX_Error));
gameexit(tempbuf);
}
@ -314,20 +318,20 @@ int xyzsound(short num,short i,long x,long y,long z)
switch (num)
{
case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE:
case RPG_EXPLODE:
if (sndist > (6144))
sndist = 6144;
if (sector[ps[screenpeek].cursectnum].lotag == 2)
pitch -= 1024;
break;
default:
if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
pitch = -768;
if (sndist > 31444 && PN != MUSICANDSFX)
return -1;
break;
case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE:
case RPG_EXPLODE:
if (sndist > (6144))
sndist = 6144;
if (sector[ps[screenpeek].cursectnum].lotag == 2)
pitch -= 1024;
break;
default:
if (sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
pitch = -768;
if (sndist > 31444 && PN != MUSICANDSFX)
return -1;
break;
}
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;
}
if (Sound[num].ptr == 0) { if (loadsound(num) == 0) return 0; }
if (Sound[num].ptr == 0)
{
if (loadsound(num) == 0) return 0;
}
else
{
if (Sound[num].lock < 200)
@ -420,7 +427,10 @@ void sound(short num)
}
else pitch = pitchs;
if (Sound[num].ptr == 0) { if (loadsound(num) == 0) return; }
if (Sound[num].ptr == 0)
{
if (loadsound(num) == 0) return;
}
else
{
if (Sound[num].lock < 200)
@ -548,17 +558,17 @@ void pan3dsound(void)
switch (j)
{
case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE:
case RPG_EXPLODE:
if (sndist > (6144)) sndist = (6144);
break;
default:
if (sndist > 31444 && PN != MUSICANDSFX)
{
stopsound(j);
continue;
}
case PIPEBOMB_EXPLODE:
case LASERTRIP_EXPLODE:
case RPG_EXPLODE:
if (sndist > (6144)) sndist = (6144);
break;
default:
if (sndist > 31444 && PN != MUSICANDSFX)
{
stopsound(j);
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)
{
if (i == -1) {
if (i == -1)
{
if (Sound[num].lock == 200)
return 1;
else return 0;

View file

@ -27,12 +27,14 @@
#define TAB_CONFIG 0
#define TAB_MESSAGES 1
static struct {
static struct
{
int fullscreen;
int xdim3d, ydim3d, bpp3d;
int forcesetup;
int usemouse, usejoy;
} settings;
}
settings;
extern int gtkenabled;
@ -64,7 +66,8 @@ static void SetPage(int 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
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_container_foreach(GTK_CONTAINER(lookup_widget(startwin,"configvlayout")),
(GtkCallback)gtk_widget_set_sensitive, (gpointer)n);
@ -80,10 +83,16 @@ static void PopulateForm(void)
char buf[64];
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 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp3d) i++; else break; }
for (; cd[i]; i++) {
for (i=0; cd[i];)
{
if (cd[i] >= settings.bpp3d) i++;
else break;
}
for (; cd[i]; i++)
{
mode3d = checkvideomode(&settings.xdim3d, &settings.ydim3d, cd[i], settings.fullscreen, 1);
if (mode3d < 0) continue;
settings.bpp3d = cd[i];
@ -98,14 +107,16 @@ static void PopulateForm(void)
modes3d = GTK_LIST_STORE(gtk_combo_box_get_model(box3d));
gtk_list_store_clear(modes3d);
for (i=0; i<validmodecnt; i++) {
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// all modes get added to the 3D mode list
Bsprintf(buf, "%ld x %ld %dbpp", validmode[i].xdim, validmode[i].ydim, validmode[i].bpp);
gtk_list_store_append(modes3d, &iter);
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);
gtk_combo_box_set_active_iter(box3d, &iter);
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)
{
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
if (mode == TAB_CONFIG)
{
retval = 0;
gtk_main_quit();
}
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_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)
{
if (mode == TAB_CONFIG) { retval = 0; gtk_main_quit(); }
if (mode == TAB_CONFIG)
{
retval = 0;
gtk_main_quit();
}
else quitevent++;
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;
startwin = create_window();
if (startwin) {
if (startwin)
{
SetPage(TAB_MESSAGES);
gtk_widget_show(startwin);
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));
gtk_text_buffer_get_end_iter(textbuffer, &enditer);
for (aptr = bptr = str; *aptr != 0;) {
switch (*bptr) {
case '\b':
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr)-1);
for (aptr = bptr = str; *aptr != 0;)
{
switch (*bptr)
{
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)
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
gtk_text_buffer_backspace(textbuffer, &enditer, FALSE, TRUE);
#else
{
GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
}
{
GtkTextIter iter2 = enditer;
gtk_text_iter_backward_cursor_position(&iter2);
//FIXME: this seems be deleting one too many chars somewhere!
if (!gtk_text_iter_equal(&iter2, &enditer))
gtk_text_buffer_delete_interactive(textbuffer, &iter2, &enditer, TRUE);
}
#endif
aptr = ++bptr;
break;
case 0:
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr;
break;
case '\r': // FIXME
default:
bptr++;
break;
aptr = ++bptr;
break;
case 0:
if (bptr > aptr)
gtk_text_buffer_insert(textbuffer, &enditer, (const gchar *)aptr, (gint)(bptr-aptr));
aptr = bptr;
break;
case '\r': // FIXME
default:
bptr++;
break;
}
}
@ -607,7 +628,8 @@ int startwin_run(void)
gtk_main();
SetPage(TAB_MESSAGES);
if (retval) {
if (retval)
{
ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim3d;
ScreenHeight = settings.ydim3d;

View file

@ -26,17 +26,22 @@
static struct audioenumdrv *wavedevs = NULL;
static struct {
static struct
{
int fullscreen;
int xdim, ydim, bpp;
int forcesetup;
int usemouse, usejoy;
char selectedgrp[BMAX_PATH+1];
int game;
} settings;
}
settings;
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;
#define POPULATE_VIDEO 1
@ -49,16 +54,23 @@ static void PopulateForm(int pgs)
char buf[256];
int i,j;
if (pgs & POPULATE_VIDEO) {
if (pgs & POPULATE_VIDEO)
{
int mode;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCVMODE);
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 };
for (i=0; cd[i];) { if (cd[i] >= settings.bpp) i++; else break; }
for (; cd[i]; i++) {
for (i=0; cd[i];)
{
if (cd[i] >= settings.bpp) i++;
else break;
}
for (; cd[i]; i++)
{
mode = checkvideomode(&settings.xdim, &settings.ydim, cd[i], settings.fullscreen, 1);
if (mode < 0) continue;
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));
ComboBox_ResetContent(hwnd);
for (i=0; i<validmodecnt; i++) {
for (i=0; i<validmodecnt; i++)
{
if (validmode[i].fs != settings.fullscreen) continue;
// 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;
char *n;
hwnd = GetDlgItem(pages[TAB_CONFIG], IDCSOUNDDRV);
ComboBox_ResetContent(hwnd);
if (wavedevs) {
if (wavedevs)
{
d = wavedevs->devs;
for (i=0; wavedevs->drvs[i]; i++) {
for (i=0; wavedevs->drvs[i]; i++)
{
strcpy(buf, wavedevs->drvs[i]);
if (d->devs) {
if (d->devs)
{
strcat(buf, ":");
n = buf + strlen(buf);
for (j=0; d->devs[j]; j++) {
for (j=0; d->devs[j]; j++)
{
strcpy(n, d->devs[j]);
ComboBox_AddString(hwnd, buf);
}
} else {
}
else
{
ComboBox_AddString(hwnd, buf);
}
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));
}
if (pgs & POPULATE_GAME) {
if (pgs & POPULATE_GAME)
{
struct grpfile *fg;
int i, j;
char buf[128+BMAX_PATH];
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;
if (i == numgrpfiles) continue; // unrecognised grp file
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)
{
switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE) {
int i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
if (i != CB_ERR) {
settings.xdim = validmode[i].xdim;
settings.ydim = validmode[i].ydim;
settings.bpp = validmode[i].bpp;
}
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDCFULLSCREEN:
settings.fullscreen = !settings.fullscreen;
PopulateForm(POPULATE_VIDEO);
return TRUE;
case IDCVMODE:
if (HIWORD(wParam) == CBN_SELCHANGE)
{
int i;
i = ComboBox_GetCurSel((HWND)lParam);
if (i != CB_ERR) i = ComboBox_GetItemData((HWND)lParam, i);
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;
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;
break;
default:
break;
}
break;
default:
break;
}
return FALSE;
}
static INT_PTR CALLBACK GamePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDGDATA: {
int i;
if (HIWORD(wParam) != LBN_SELCHANGE) break;
i = ListBox_GetCurSel((HWND)lParam);
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;
switch (uMsg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDGDATA:
{
int i;
if (HIWORD(wParam) != LBN_SELCHANGE) break;
i = ListBox_GetCurSel((HWND)lParam);
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:
break;
}
break;
default:
break;
}
return FALSE;
}
@ -226,182 +256,206 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
static HBITMAP hbmp = NULL;
HDC hdc;
switch (uMsg) {
case WM_INITDIALOG: {
HWND hwnd;
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
switch (uMsg)
{
case WM_INITDIALOG:
{
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));
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);
// 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;
// Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r));
// 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);
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;
xoffset = r.right;
yoffset = r.bottom - rdlg.bottom;
// 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);
// 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;
// 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);
// 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);
// 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 };
ListBox_SetTabStops(GetDlgItem(pages[TAB_GAME], IDGDATA), 1, tabs);
TCITEM tab;
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);
}
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;
return FALSE;
}
if (pages[TAB_GAME]) {
DestroyWindow(pages[TAB_GAME]);
pages[TAB_GAME] = NULL;
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;
}
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:
case WM_CLOSE:
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;
case WM_DESTROY:
if (hbmp)
{
DeleteObject(hbmp);
hbmp = NULL;
}
default:
break;
if (pages[TAB_GAME])
{
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;
@ -416,7 +470,8 @@ int startwin_open(void)
icc.dwICC = ICC_TAB_CLASSES;
InitCommonControlsEx(&icc);
startupdlg = CreateDialog((HINSTANCE)win_gethinstance(), MAKEINTRESOURCE(WIN_STARTWIN), NULL, startup_dlgproc);
if (startupdlg) {
if (startupdlg)
{
SetPage(TAB_MESSAGES);
EnableConfig(0);
return 0;
@ -453,25 +508,33 @@ int startwin_puts(const char *buf)
SendMessage(edctl, EM_SETSEL, (WPARAM)curlen, (LPARAM)curlen);
linesbefore = SendMessage(edctl, EM_GETLINECOUNT, 0,0);
p = buf;
while (*p) {
if (newline) {
while (*p)
{
if (newline)
{
SendMessage(edctl, EM_REPLACESEL, 0, (LPARAM)"\r\n");
newline = 0;
}
q = p;
while (*q && *q != '\n') q++;
memcpy(workbuf, p, q-p);
if (*q == '\n') {
if (!q[1]) {
if (*q == '\n')
{
if (!q[1])
{
newline = 1;
workbuf[q-p] = 0;
} else {
}
else
{
workbuf[q-p] = '\r';
workbuf[q-p+1] = '\n';
workbuf[q-p+2] = 0;
}
p = q+1;
} else {
}
else
{
workbuf[q-p] = 0;
p = q;
}
@ -523,23 +586,27 @@ int startwin_run(void)
strncpy(settings.selectedgrp, duke3dgrp, BMAX_PATH);
PopulateForm(-1);
while (done < 0) {
switch (GetMessage(&msg, NULL, 0,0)) {
case 0:
done = 1; break;
case -1:
return -1;
default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
while (done < 0)
{
switch (GetMessage(&msg, NULL, 0,0))
{
case 0:
done = 1;
break;
case -1:
return -1;
default:
if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
break;
}
}
SetPage(TAB_MESSAGES);
EnableConfig(0);
if (done) {
if (done)
{
ScreenMode = settings.fullscreen;
ScreenWidth = settings.xdim;
ScreenHeight = settings.ydim;
@ -551,10 +618,12 @@ int startwin_run(void)
gametype = settings.game;
}
if (wavedevs) {
if (wavedevs)
{
struct audioenumdev *d, *e;
free(wavedevs->drvs);
for (e=wavedevs->devs; e; e=d) {
for (e=wavedevs->devs; e; e=d)
{
d = e->next;
if (e->devs) free(e->devs);
free(e);

View file

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

View file

@ -72,7 +72,8 @@ void Error(char *error, ...)
Shutdown();
if (error) {
if (error)
{
va_start(va, error);
vsprintf(buf, error, 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.");
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);
return 1;
} else WaitForSingleObject(pi.hProcess,INFINITE);
}
else WaitForSingleObject(pi.hProcess,INFINITE);
return 0;
}