about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-30 15:43:19 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-30 15:43:19 +0000
commit8ac1164a89cf3d004c7d195ef70a450239c073f5 (patch)
tree2b88a9742708bd583ae552450193b64444e17d65 /src
parenta35f7cd4b4021046efd18d2fe62251fa5620828a (diff)
downloadzcatch-8ac1164a89cf3d004c7d195ef70a450239c073f5.tar.gz
zcatch-8ac1164a89cf3d004c7d195ef70a450239c073f5.zip
fixed saving of complex binds
Diffstat (limited to 'src')
-rw-r--r--src/game/client/gc_console.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp
index 431c9d6f..91461a47 100644
--- a/src/game/client/gc_console.cpp
+++ b/src/game/client/gc_console.cpp
@@ -332,12 +332,27 @@ static void con_dump_binds(void *result, void *user_data)
 void binds_save()
 {
 	char buffer[256];
+	char *end = buffer+sizeof(buffer)-8;
 	client_save_line("unbindall");
 	for(int i = 0; i < KEY_LAST; i++)
 	{
 		if(keybindings[i][0] == 0)
 			continue;
-		str_format(buffer, sizeof(buffer), "bind %s %s", inp_key_name(i), keybindings[i]);
+		str_format(buffer, sizeof(buffer), "bind %s ", inp_key_name(i));
+		
+		// process the string. we need to escape some characters
+		const char *src = keybindings[i];
+		char *dst = buffer + strlen(buffer);
+		*dst++ = '"';
+		while(*src && dst < end)
+		{
+			if(*src == '"' || *src == '\\') // escape \ and "
+				*dst++ = '\\';
+			*dst++ = *src++;
+		}
+		*dst++ = '"';
+		*dst++ = 0;
+		
 		client_save_line(buffer);
 	}
 }