From 4ce41d5079916ed72275b646ffee136081a784cf Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 12 Aug 2008 12:50:20 +0000 Subject: [PATCH] Enhancements to -cfg: now offers the option to import existing config settings from duke3d.cfg, and binds.cfg is now cfgname_binds.cfg so individual configs can have their own. This is good for mods that change some of the function names (like Duke Plus) because otherwise running EDuke32 on the same cfg without the mod activated will blow away the controls for functions that don't exist. git-svn-id: https://svn.eduke32.com/eduke32@972 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/config.c | 25 +++++++-- polymer/eduke32/source/game.c | 9 +++- polymer/eduke32/source/osdcmds.c | 89 ++++++++++++++------------------ polymer/eduke32/source/player.c | 7 ++- polymer/eduke32/source/premap.c | 4 +- 5 files changed, 74 insertions(+), 60 deletions(-) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 9bf981d2f..6be9a7875 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -597,7 +597,7 @@ extern palette_t default_crosshair_colors; int32 CONFIG_ReadSetup(void) { - int32 dummy, i; + int32 dummy, i = 0; char commmacro[] = "CommbatMacro# "; extern int32 CommandWeaponChoice; @@ -609,6 +609,15 @@ int32 CONFIG_ReadSetup(void) pathsearchmode = 1; if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 ud.config.scripthandle = SCRIPT_Load(setupfilename); + else if (SafeFileExists("duke3d.cfg") && ud.config.scripthandle < 0) + { + Bsprintf(tempbuf,"The configuration file \"%s\" was not found. " + "Would you like to import configuration data " + "from \"duke3d.cfg\"?",setupfilename); + + i=wm_ynbox("Import Configuration Settings",tempbuf); + if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg"); + } pathsearchmode = 0; if (ud.config.scripthandle < 0) return -1; @@ -851,7 +860,11 @@ int32 CONFIG_ReadSetup(void) void CONFIG_WriteBinds(void) // save binds and aliases to disk { int i; - FILE *fp = fopen("binds.cfg", "wt"); + FILE *fp; + char *ptr = Bstrdup(setupfilename); + + Bsprintf(tempbuf,"%s_binds.cfg",strtok(ptr,".")); + fp = fopen(tempbuf, "wt"); if (fp) { @@ -874,10 +887,14 @@ void CONFIG_WriteBinds(void) // save binds and aliases to disk fprintf(fp,"%s \"%d\"\n",cvar[i].name,*(int*)cvar[i].var); */ fclose(fp); - OSD_Printf("Wrote binds.cfg\n"); + Bsprintf(tempbuf,"Wrote %s_binds.cfg\n",ptr); + OSD_Printf(tempbuf); + Bfree(ptr); return; } - OSD_Printf("Error writing binds.cfg: %s\n",strerror(errno)); + Bsprintf(tempbuf,"Error writing %s_binds.cfg: %s\n",ptr,strerror(errno)); + OSD_Printf(tempbuf); + Bfree(ptr); } void CONFIG_WriteSetup(void) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 636dbeb13..04b84b29c 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -10922,7 +10922,14 @@ void app_main(int argc,const char **argv) clearsoundlocks(); OSD_Exec("autoexec.cfg"); - OSD_Exec("binds.cfg"); + + { + char *ptr = Bstrdup(setupfilename); + Bsprintf(tempbuf,"%s_binds.cfg",strtok(ptr,".")); + Bfree(ptr); + } + + OSD_Exec(tempbuf); if (ud.warp_on > 1 && ud.multimode < 2) { diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index cb48b63f6..fd3f26671 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -815,58 +815,49 @@ static int osdcmd_give(const osdfuncparm_t *parm) { int i; - if (numplayers == 1 && g_player[myconnectindex].ps->gm & MODE_GAME) + if (numplayers != 1 || (g_player[myconnectindex].ps->gm & MODE_GAME) == 0 || + g_player[myconnectindex].ps->dead_flag != 0) { - if (g_player[myconnectindex].ps->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")) - { - osdcmd_cheatsinfo_stat.cheatnum = 1; - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "health")) - { - sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1; - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "weapons")) - { - osdcmd_cheatsinfo_stat.cheatnum = 21; - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "ammo")) - { - for (i=PISTOL_WEAPON;imax_ammo_amount[i]); - } - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "armor")) - { - g_player[myconnectindex].ps->shield_amount = 100; - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "keys")) - { - osdcmd_cheatsinfo_stat.cheatnum = 23; - return OSDCMD_OK; - } - else if (!Bstrcasecmp(parm->parms[0], "inventory")) - { - osdcmd_cheatsinfo_stat.cheatnum = 22; - return OSDCMD_OK; - } + OSD_Printf("give: Cannot give while dead or not in a single-player game.\n"); + return OSDCMD_OK; } - else + + if (parm->numparms != 1) return OSDCMD_SHOWHELP; + + if (!Bstrcasecmp(parm->parms[0], "all")) { - OSD_Printf("give: Not in a single-player game.\n"); + osdcmd_cheatsinfo_stat.cheatnum = 1; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "health")) + { + sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health<<1; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "weapons")) + { + osdcmd_cheatsinfo_stat.cheatnum = 21; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "ammo")) + { + for (i=MAX_WEAPONS-(VOLUMEONE?6:1)-1;i>=PISTOL_WEAPON;i--) + addammo(i,g_player[myconnectindex].ps,g_player[myconnectindex].ps->max_ammo_amount[i]); + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "armor")) + { + g_player[myconnectindex].ps->shield_amount = 100; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "keys")) + { + osdcmd_cheatsinfo_stat.cheatnum = 23; + return OSDCMD_OK; + } + else if (!Bstrcasecmp(parm->parms[0], "inventory")) + { + osdcmd_cheatsinfo_stat.cheatnum = 22; return OSDCMD_OK; } return OSDCMD_SHOWHELP; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 35e680234..311006cd3 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2480,9 +2480,8 @@ void displayweapon(int snum) if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) { - short kb_frames[] = {0,1,2},l; - - l = 195-12+weapon_xoffset; + static short kb_frames[] = {0,1,2}; + int l = 195-12+weapon_xoffset; if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) l -= 3; @@ -4896,7 +4895,7 @@ SHOOTINCODE: } } } - else if ((*kb)) + else if (*kb) { if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) { diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 9ccf76573..fe63f02e8 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1591,9 +1591,9 @@ extern int voting, vote_map, vote_episode; void getlevelfromfilename(const char *fn, char *volume, char *level) { - for (*volume=0;*volume=0;(*volume)--) { - for (*level=0;*level=0;(*level)--) { if (map[(*volume*MAXLEVELS)+*level].filename != NULL) if (!Bstrcasecmp(fn, map[(*volume*MAXLEVELS)+*level].filename))