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
This commit is contained in:
terminx 2008-08-12 12:50:20 +00:00
parent 68e7e307ae
commit 4ce41d5079
5 changed files with 74 additions and 60 deletions

View file

@ -597,7 +597,7 @@ extern palette_t default_crosshair_colors;
int32 CONFIG_ReadSetup(void) int32 CONFIG_ReadSetup(void)
{ {
int32 dummy, i; int32 dummy, i = 0;
char commmacro[] = "CommbatMacro# "; char commmacro[] = "CommbatMacro# ";
extern int32 CommandWeaponChoice; extern int32 CommandWeaponChoice;
@ -609,6 +609,15 @@ int32 CONFIG_ReadSetup(void)
pathsearchmode = 1; pathsearchmode = 1;
if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211
ud.config.scripthandle = SCRIPT_Load(setupfilename); 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; pathsearchmode = 0;
if (ud.config.scripthandle < 0) return -1; 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 void CONFIG_WriteBinds(void) // save binds and aliases to disk
{ {
int i; 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) 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); fprintf(fp,"%s \"%d\"\n",cvar[i].name,*(int*)cvar[i].var);
*/ */
fclose(fp); fclose(fp);
OSD_Printf("Wrote binds.cfg\n"); Bsprintf(tempbuf,"Wrote %s_binds.cfg\n",ptr);
OSD_Printf(tempbuf);
Bfree(ptr);
return; 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) void CONFIG_WriteSetup(void)

View file

@ -10922,7 +10922,14 @@ void app_main(int argc,const char **argv)
clearsoundlocks(); clearsoundlocks();
OSD_Exec("autoexec.cfg"); 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) if (ud.warp_on > 1 && ud.multimode < 2)
{ {

View file

@ -815,58 +815,49 @@ static int osdcmd_give(const osdfuncparm_t *parm)
{ {
int i; 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 or not in a single-player game.\n");
{ return OSDCMD_OK;
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;i<MAX_WEAPONS-(VOLUMEONE?6:1);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;
}
} }
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_OK;
} }
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;

View file

@ -2480,9 +2480,8 @@ void displayweapon(int snum)
if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1)
{ {
short kb_frames[] = {0,1,2},l; static short kb_frames[] = {0,1,2};
int l = 195-12+weapon_xoffset;
l = 195-12+weapon_xoffset;
if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON])
l -= 3; l -= 3;
@ -4896,7 +4895,7 @@ SHOOTINCODE:
} }
} }
} }
else if ((*kb)) else if (*kb)
{ {
if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON)
{ {

View file

@ -1591,9 +1591,9 @@ extern int voting, vote_map, vote_episode;
void getlevelfromfilename(const char *fn, char *volume, char *level) void getlevelfromfilename(const char *fn, char *volume, char *level)
{ {
for (*volume=0;*volume<MAXVOLUMES;(*volume)++) for (*volume=MAXVOLUMES-1;*volume>=0;(*volume)--)
{ {
for (*level=0;*level<MAXLEVELS;(*level)++) for (*level=MAXLEVELS-1;*level>=0;(*level)--)
{ {
if (map[(*volume*MAXLEVELS)+*level].filename != NULL) if (map[(*volume*MAXLEVELS)+*level].filename != NULL)
if (!Bstrcasecmp(fn, map[(*volume*MAXLEVELS)+*level].filename)) if (!Bstrcasecmp(fn, map[(*volume*MAXLEVELS)+*level].filename))