Changeset - r27605:d9db6344e134
[Not reviewed]
master
0 1 0
Rubidium - 12 months ago 2023-06-18 17:24:12
rubidium@openttd.org
Codechange: refactor code to remove need for stredup
1 file changed with 3 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -1275,16 +1275,14 @@ DEF_CONSOLE_CMD(ConStartAI)
 
		 * try again with the assumption everything right of the dot is
 
		 * the version the user wants to load. */
 
		if (!config->HasScript()) {
 
			char *name = stredup(argv[1]);
 
			char *e = strrchr(name, '.');
 
			const char *e = strrchr(argv[1], '.');
 
			if (e != nullptr) {
 
				*e = '\0';
 
				size_t name_length = e - argv[1];
 
				e++;
 

	
 
				int version = atoi(e);
 
				config->Change(name, version, true);
 
				config->Change(std::string(argv[1], name_length), version, true);
 
			}
 
			free(name);
 
		}
 

	
 
		if (!config->HasScript()) {
0 comments (0 inline, 0 general)