Skip to content

Commit

Permalink
SRB2 2.1.7 release
Browse files Browse the repository at this point in the history
  • Loading branch information
alama committed Apr 14, 2014
1 parent 2bd6573 commit 02a3b07
Show file tree
Hide file tree
Showing 36 changed files with 734 additions and 507 deletions.
108 changes: 71 additions & 37 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,39 @@ void COM_AddCommand(const char *name, com_func_t func)
com_commands = cmd;
}

/** Adds a console command for Lua.
* No I_Errors allowed; return a negative code instead.
*
* \param name Name of the command.
*/
int COM_AddLuaCommand(const char *name)
{
xcommand_t *cmd;

// fail if the command is a variable name
if (CV_StringValue(name)[0] != '\0')
return -1;

// command already exists
for (cmd = com_commands; cmd; cmd = cmd->next)
{
if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{
// replace the built in command.
cmd->function = COM_Lua_f;
return 1;
}
}

// Add a new command.
cmd = ZZ_Alloc(sizeof *cmd);
cmd->name = name;
cmd->function = COM_Lua_f;
cmd->next = com_commands;
com_commands = cmd;
return 0;
}

/** Tests if a command exists.
*
* \param com_name Name to test for.
Expand Down Expand Up @@ -558,7 +591,7 @@ static void COM_CEchoFlags_f(void)
HU_SetCEchoFlags(atoi(arg));
}
else
CONS_Printf(M_GetText("cechoflags <flags>: set CEcho flags, prepend with 0x to use hexadecimal"));
CONS_Printf(M_GetText("cechoflags <flags>: set CEcho flags, prepend with 0x to use hexadecimal\n"));
}

/** Sets the duration for CECHO commands to stay on the screen
Expand Down Expand Up @@ -1017,6 +1050,8 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
if (var->PossibleValue)
{
INT32 v = atoi(valstr);
if (!v && valstr[0] != '0')
v = INT32_MIN; // Invalid integer trigger

if (var->PossibleValue[0].strvalue && !stricmp(var->PossibleValue[0].strvalue, "MIN")) // bounded cvar
{
Expand All @@ -1029,20 +1064,23 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
if (!var->PossibleValue[i].strvalue)
I_Error("Bounded cvar \"%s\" without maximum!\n", var->name);
#endif
if (v < var->PossibleValue[0].value || !stricmp(valstr, "MIN"))

if ((v != INT32_MIN && v < var->PossibleValue[0].value) || !stricmp(valstr, "MIN"))
{
v = var->PossibleValue[0].value;
valstr = var->PossibleValue[0].strvalue;
override = true;
overrideval = v;
}
if (v > var->PossibleValue[i].value || !stricmp(valstr, "MAX"))
else if ((v != INT32_MIN && v > var->PossibleValue[i].value) || !stricmp(valstr, "MAX"))
{
v = var->PossibleValue[i].value;
valstr = var->PossibleValue[i].strvalue;
override = true;
overrideval = v;
}
if (v == INT32_MIN)
goto badinput;
}
else
{
Expand All @@ -1052,48 +1090,32 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
for (i = 0; var->PossibleValue[i].strvalue; i++)
if (!stricmp(var->PossibleValue[i].strvalue, valstr))
goto found;
if (!v)
if (strcmp(valstr, "0"))
goto error;
// check INT32 now
for (i = 0; var->PossibleValue[i].strvalue; i++)
if (v == var->PossibleValue[i].value)
goto found;

error:
// not found

// But wait, there's hope!
if (var->PossibleValue == CV_OnOff
|| var->PossibleValue == CV_YesNo)
if (v != INT32_MIN)
{
INT32 hopevalue = -1;

if (!stricmp(valstr, "on"))
hopevalue = 1;
else if (!stricmp(valstr, "off"))
hopevalue = 0;
else if (!stricmp(valstr, "yes"))
hopevalue = 1;
else if (!stricmp(valstr, "no"))
hopevalue = 0;

if (hopevalue != -1)
// check INT32 now
for (i = 0; var->PossibleValue[i].strvalue; i++)
if (v == var->PossibleValue[i].value)
goto found;
}
// Not found ... but wait, there's hope!
if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo)
{
overrideval = -1;
if (!stricmp(valstr, "on") || !stricmp(valstr, "yes"))
overrideval = 1;
else if (!stricmp(valstr, "off") || !stricmp(valstr, "no"))
overrideval = 0;

if (overrideval != -1)
{
for (i = 0; var->PossibleValue[i].strvalue; i++)
if (hopevalue == var->PossibleValue[i].value)
if (overrideval == var->PossibleValue[i].value)
goto found;
}
}

// ...or not.
if (var != &cv_nextmap) // Suppress errors for cv_nextmap
CONS_Printf(M_GetText("\"%s\" is not a possible value for \"%s\"\n"), valstr, var->name);

if (var->defaultvalue == valstr)
I_Error("Variable %s default value \"%s\" is not a possible value\n",
var->name, var->defaultvalue);
return;
goto badinput;
found:
var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue;
Expand Down Expand Up @@ -1141,6 +1163,18 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
#endif
if (var->flags & CV_CALL && !stealth)
var->func();

return;

// landing point for possiblevalue failures
badinput:

if (var != &cv_nextmap) // Suppress errors for cv_nextmap
CONS_Printf(M_GetText("\"%s\" is not a possible value for \"%s\"\n"), valstr, var->name);

// default value not valid... ?!
if (var->defaultvalue == valstr)
I_Error("Variable %s default value \"%s\" is not a possible value\n", var->name, var->defaultvalue);
}

//
Expand Down
1 change: 1 addition & 0 deletions src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
typedef void (*com_func_t)(void);

void COM_AddCommand(const char *name, com_func_t func);
int COM_AddLuaCommand(const char *name);

size_t COM_Argc(void);
const char *COM_Argv(size_t arg); // if argv > argc, returns empty string
Expand Down
9 changes: 4 additions & 5 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,15 +1086,14 @@ void D_SRB2Main(void)
#endif
D_CleanFile();

#if 1 // md5s last updated 3/22/14
#if 1 // md5s last updated 4/13/14

// Check MD5s of autoloaded files
W_VerifyFileMD5(0, "ac309fb3c7d4b5b685e2cd26beccf0e8"); // srb2.srb/srb2.wad
W_VerifyFileMD5(1, "a894044b555dfcc71865cee16a996e88"); // zones.dta
W_VerifyFileMD5(2, "4c410c1de6e0440cc5b2858dcca80c3e"); // player.dta
W_VerifyFileMD5(1, "e956466eff2c79f7b1cdefad24761bce"); // zones.dta
W_VerifyFileMD5(2, "95a4cdbed287323dd361243f357a5fd2"); // player.dta
W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
W_VerifyFileMD5(4, "386ab4ffc8c9fb0fa62f788a16e5c218"); // patch.dta

W_VerifyFileMD5(4, "1f37fe7bcc608a23eadb0e2c2d7c7124"); // patch.dta
// don't check music.dta because people like to modify it, and it doesn't matter if they do
// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
#endif
Expand Down
18 changes: 16 additions & 2 deletions src/d_netcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static void Command_Skynum_f(void);

static void Command_ExitLevel_f(void);
static void Command_Showmap_f(void);
static void Command_Mapmd5_f(void);

static void Command_Teamchange_f(void);
static void Command_Teamchange2_f(void);
Expand Down Expand Up @@ -330,7 +331,6 @@ consvar_t cv_itemfinder = {"itemfinder", "Off", CV_CALL, CV_OnOff, ItemFinder_On
consvar_t cv_match_scoring = {"matchscoring", "Normal", CV_NETVAR|CV_CHEAT, match_scoring_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_overtime = {"overtime", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};

consvar_t cv_realnames = {"realnames", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};

consvar_t cv_timetic = {"timerres", "Normal", 0, timetic_cons_t, NULL, CV_SAVE, NULL, NULL, 0, 0, NULL}; // use tics in display
Expand Down Expand Up @@ -431,6 +431,7 @@ void D_RegisterServerCommands(void)
COM_AddCommand("retry", Command_Retry_f);
COM_AddCommand("exitlevel", Command_ExitLevel_f);
COM_AddCommand("showmap", Command_Showmap_f);
COM_AddCommand("mapmd5", Command_Mapmd5_f);

COM_AddCommand("addfile", Command_Addfile);
COM_AddCommand("listwad", Command_ListWADS_f);
Expand Down Expand Up @@ -643,7 +644,6 @@ void D_RegisterClientCommands(void)
#ifdef SEENAMES
CV_RegisterVar(&cv_seenames);
#endif
CV_RegisterVar(&cv_realnames);
CV_RegisterVar(&cv_rollingdemos);
CV_RegisterVar(&cv_netstat);

Expand Down Expand Up @@ -3866,6 +3866,20 @@ static void Command_Showmap_f(void)
CONS_Printf(M_GetText("You must be in a level to use this.\n"));
}

static void Command_Mapmd5_f(void)
{
if (gamestate == GS_LEVEL)
{
INT32 i;
char md5tmp[33];
for (i = 0; i < 16; ++i)
sprintf(&md5tmp[i*2], "%02x", mapmd5[i]);
CONS_Printf("%s: %s\n", G_BuildMapName(gamemap), md5tmp);
}
else
CONS_Printf(M_GetText("You must be in a level to use this.\n"));
}

static void Command_ExitLevel_f(void)
{
if (!(netgame || (multiplayer && gametype != GT_COOP)) && !cv_debug)
Expand Down
2 changes: 1 addition & 1 deletion src/d_netcmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extern consvar_t cv_overtime;
extern consvar_t cv_startinglives;

// for F_finale.c
extern consvar_t cv_realnames, cv_rollingdemos;
extern consvar_t cv_rollingdemos;

extern consvar_t cv_resetmusic;

Expand Down
6 changes: 4 additions & 2 deletions src/d_netfil.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#include "md5.h"
#include "filesrch.h"

#include <errno.h>

static void SendFile(INT32 node, const char *filename, UINT8 fileid);

// sender structure
Expand Down Expand Up @@ -652,7 +654,7 @@ void Got_Filetxpak(void)
{
if (fileneeded[filenum].phandle) I_Error("Got_Filetxpak: allready open file\n");
fileneeded[filenum].phandle = fopen(fileneeded[filenum].filename, "wb");
if (!fileneeded[filenum].phandle) I_Error("Can't create file %s: disk full ?",fileneeded[filenum].filename);
if (!fileneeded[filenum].phandle) I_Error("Can't create file %s: %s",fileneeded[filenum].filename, strerror(errno));
CONS_Printf("\r%s...\n",fileneeded[filenum].filename);
fileneeded[filenum].currentsize = 0;
fileneeded[filenum].status = FS_DOWNLOADING;
Expand All @@ -672,7 +674,7 @@ void Got_Filetxpak(void)
// we can receive packet in the wrong order, anyway all os support gaped file
fseek(fileneeded[filenum].phandle,pos,SEEK_SET);
if (fwrite(netbuffer->u.filetxpak.data,size,1,fileneeded[filenum].phandle)!=1)
I_Error("Can't write %s: disk full ? or %s\n",fileneeded[filenum].filename, strerror(ferror(fileneeded[filenum].phandle)));
I_Error("Can't write to %s: %s\n",fileneeded[filenum].filename, strerror(ferror(fileneeded[filenum].phandle)));
fileneeded[filenum].currentsize += size;

// finished?
Expand Down
23 changes: 10 additions & 13 deletions src/dehacked.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ static powertype_t get_power(const char *word);
#endif

boolean deh_loaded = false;
boolean modcredits = false; // Whether a mod creator's name will show in the credits.
char modcreditname[32];
static int dbg_line;

static boolean gamedataadded = false;
Expand Down Expand Up @@ -3285,12 +3283,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad)
}
DEH_WriteUndoline(word, word2, UNDO_HEADER);
}
else if (fastcmp(word, "MODBY"))
{
memset(modcreditname, 0, sizeof(char) * 32);
strcpy(modcreditname, origpos+6);
modcredits = true;
}
/* else if (fastcmp(word, "ANIMTEX"))
{
readAnimTex(f, i);
Expand Down Expand Up @@ -4451,6 +4443,8 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit
"S_CYBRAKDEMONTARGETRETICULE13",
"S_CYBRAKDEMONTARGETRETICULE14",

"S_CYBRAKDEMONTARGETDOT",

"S_CYBRAKDEMONNAPALMBOMBLARGE_FLY1",
"S_CYBRAKDEMONNAPALMBOMBLARGE_FLY2",
"S_CYBRAKDEMONNAPALMBOMBLARGE_FLY3",
Expand Down Expand Up @@ -6648,6 +6642,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s
"MT_CYBRAKDEMON_FLAMESHOT",
"MT_CYBRAKDEMON_FLAMEREST",
"MT_CYBRAKDEMON_TARGET_RETICULE",
"MT_CYBRAKDEMON_TARGET_DOT",
"MT_CYBRAKDEMON_NAPALM_BOMB_LARGE",
"MT_CYBRAKDEMON_NAPALM_BOMB_SMALL",
"MT_CYBRAKDEMON_NAPALM_FLAMES",
Expand Down Expand Up @@ -7301,12 +7296,12 @@ static const char *const POWERS_LIST[] = {

// Weapon ammunition
"INFINITYRING",
"BOUNCERING",
"RAILRING",
"AUTOMATICRING",
"EXPLOSIONRING",
"BOUNCERING",
"SCATTERRING",
"GRENADERING",
"EXPLOSIONRING",
"RAILRING",

// Power Stones
"EMERALDS", // stored like global 'emeralds' variable
Expand Down Expand Up @@ -7441,6 +7436,7 @@ struct {
{"TOL_MATCH",TOL_MATCH},
{"TOL_TAG",TOL_TAG},
{"TOL_CTF",TOL_CTF},
{"TOL_CUSTOM",TOL_CUSTOM},
{"TOL_2D",TOL_2D},
{"TOL_MARIO",TOL_MARIO},
{"TOL_NIGHTS",TOL_NIGHTS},
Expand Down Expand Up @@ -7926,8 +7922,9 @@ static fixed_t find_const(const char **rword)
free(word);
return r;
}
if (*word >= 'A' && !*(word+1)) { // Turn a single A-z symbol into numbers, like sprite frames.
r = *word-'A';
if (!*(word+1) && // Turn a single A-z symbol into numbers, like sprite frames.
(*word >= 'A' && *word <= 'Z') || (*word >= 'a' && *word <= 'z')) {
r = R_Char2Frame(*word);
free(word);
return r;
}
Expand Down
3 changes: 1 addition & 2 deletions src/dehacked.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ const char *LUA_GetActionName(void *action);
void LUA_SetActionByName(void *state, const char *actiontocompare);
#endif

extern boolean deh_loaded, modcredits;
extern char modcreditname[32];
extern boolean deh_loaded;

#define MAXRECURSION 30
extern const char *superactions[MAXRECURSION];
Expand Down
Loading

0 comments on commit 02a3b07

Please sign in to comment.