Changeset - r4278:60a9f710b44f
[Not reviewed]
master
0 3 0
Darkvater - 18 years ago 2006-08-15 07:37:01
darkvater@openttd.org
(svn r5908) - Codechange (r5903): Move the retrieval of the new value of a patch to console_cmds.c, so there is no need for that function in settings.c
3 files changed with 7 insertions and 12 deletions:
0 comments (0 inline, 0 general)
console_cmds.c
Show inline comments
 
@@ -1339,13 +1339,14 @@ DEF_CONSOLE_CMD(ConPatch)
 

	
 
	if (argc == 1 || argc > 3) return false;
 

	
 
	if (argc == 2) {
 
		IConsoleGetPatchSetting(argv[1]);
 
	} else {
 
		IConsoleSetPatchSetting(argv[1], argv[2]);
 
		int32 val;
 
		if (GetArgumentInteger(&val, argv[2])) IConsoleSetPatchSetting(argv[1], val);
 
	}
 

	
 
	return true;
 
}
 
#endif /* ENABLE_NETWORK */
 

	
settings.c
Show inline comments
 
@@ -1594,36 +1594,30 @@ const SettingDesc *GetPatchFromName(cons
 
	}
 

	
 
	return NULL;
 
}
 

	
 
/* Those 2 functions need to be here, else we have to make some stuff non-static
 
 * and besides, it is also better to keep stuff like this at the same place
 
 * XXX - Perhaps back to console[_cmds].c? They are console functions after all */
 
extern bool GetArgumentInteger(uint32 *value, const char *arg);
 

	
 
void IConsoleSetPatchSetting(const char *name, const char *value)
 
 * and besides, it is also better to keep stuff like this at the same place */
 
void IConsoleSetPatchSetting(const char *name, int32 value)
 
{
 
	int32 val;
 
	uint index;
 
	const SettingDesc *sd = GetPatchFromName(name, &index);
 
	const Patches *patches_ptr;
 
	void *ptr;
 

	
 
	if (sd == NULL) {
 
		IConsolePrintF(_icolour_warn, "'%s' is an unknown patch setting.", name);
 
		return;
 
	}
 

	
 
	if (!GetArgumentInteger(&val, value)) return;
 

	
 
	patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
 
	ptr = ini_get_variable(&sd->save, patches_ptr);
 

	
 
	SetPatchValue(index, patches_ptr, val);
 
	if (sd->desc.proc != NULL) sd->desc.proc(val);
 
	SetPatchValue(index, patches_ptr, value);
 
	if (sd->desc.proc != NULL) sd->desc.proc(value);
 
}
 

	
 
void IConsoleGetPatchSetting(const char *name)
 
{
 
	char value[20];
 
	uint index;
settings.h
Show inline comments
 
@@ -74,12 +74,12 @@ static inline void *ini_get_variable(con
 
	return (object == NULL) ? sld->address : (byte*)object + (ptrdiff_t)sld->address;
 
}
 

	
 
/** The patch values that are used for new games and/or modified in config file */
 
extern Patches _patches_newgame;
 

	
 
void IConsoleSetPatchSetting(const char *name, const char *value);
 
void IConsoleSetPatchSetting(const char *name, int32 value);
 
void IConsoleGetPatchSetting(const char *name);
 
const SettingDesc *GetPatchFromName(const char *name, uint *i);
 
void SetPatchValue(uint index, const Patches *object, int32 value);
 

	
 
#endif /* SETTINGS_H */
0 comments (0 inline, 0 general)