1.1 --- a/update_tool/update_tool.cpp Sat Mar 31 17:51:08 2007 +0000
1.2 +++ b/update_tool/update_tool.cpp Sat Mar 31 20:23:59 2007 +0000
1.3 @@ -8,12 +8,12 @@
1.4
1.5 #if defined _MSC_VER
1.6 #define SEPCHAR "\\"
1.7 -#define MMPATH "|gameinfo_path|addons\\metamod\\bin"
1.8 +#define MMPATH "addons\\metamod\\bin"
1.9 #define WINDOWS_LEAN_AND_MEAN
1.10 #include <windows.h>
1.11 #elif defined __linux__
1.12 #define SEPCHAR "/"
1.13 -#define MMPATH "|gameinfo_path|addons/metamod/bin"
1.14 +#define MMPATH "addons/metamod/bin"
1.15 #include <unistd.h>
1.16 #endif
1.17
1.18 @@ -29,9 +29,85 @@
1.19 #endif
1.20 {
1.21 char gamedir[260];
1.22 + char mmpath[260];
1.23
1.24 GetGameDir(gamedir, sizeof(gamedir));
1.25
1.26 + /* Defaults */
1.27 + UTIL_Format(mmpath, sizeof(mmpath), "|gameinfo_path|%s", MMPATH);
1.28 +
1.29 + /* Read config */
1.30 + char config[260];
1.31 + UTIL_Format(config, sizeof(config), "%s" SEPCHAR "sourcemm_updater.conf", gamedir);
1.32 + FILE *fpCfg = fopen(config, "rt");
1.33 + if (fpCfg)
1.34 + {
1.35 + char cfgLine[512];
1.36 + while (!feof(fpCfg) && fgets(cfgLine, sizeof(cfgLine), fpCfg) != NULL)
1.37 + {
1.38 + char key[255];
1.39 +
1.40 + size_t keyLen = 0;
1.41 +
1.42 + /* Strip whitespace */
1.43 + char *input = cfgLine;
1.44 + while (*input != '\0' && s_isspace(*input))
1.45 + {
1.46 + input++;
1.47 + }
1.48 +
1.49 + /* Strip ending whitespace */
1.50 + size_t len = strlen(input);
1.51 + for (size_t i = len - 1;
1.52 + i >= 0 && i < len;
1.53 + i--)
1.54 + {
1.55 + if (s_isspace(input[i]))
1.56 + {
1.57 + input[i] = '\0';
1.58 + len--;
1.59 + } else {
1.60 + break;
1.61 + }
1.62 + }
1.63 +
1.64 + /* Eat stuff until we find a key */
1.65 + while (*input != '\0' && !s_isspace(*input))
1.66 + {
1.67 + if (keyLen < sizeof(key))
1.68 + {
1.69 + key[keyLen++] = *input;
1.70 + }
1.71 + input++;
1.72 + }
1.73 + key[keyLen] = '\0';
1.74 +
1.75 + /* Eat spaces until we hit an = sign */
1.76 + while (*input != '\0' && *input != '=')
1.77 + {
1.78 + input++;
1.79 + }
1.80 +
1.81 + if (*input == '=')
1.82 + {
1.83 + input++;
1.84 + }
1.85 +
1.86 + /* Eat spaces again */
1.87 + while (*input != '\0' && s_isspace(*input))
1.88 + {
1.89 + input++;
1.90 + }
1.91 +
1.92 + /* The rest is our key */
1.93 + if (strcmp(key, "mmpath") == 0)
1.94 + {
1.95 + UTIL_Format(mmpath, sizeof(mmpath), "%s", input);
1.96 + }
1.97 + }
1.98 + fclose(fpCfg);
1.99 + }
1.100 +
1.101 char old_path[260];
1.102 char new_path[260];
1.103
1.104 @@ -117,13 +193,15 @@
1.105 if (game)
1.106 {
1.107 if (strstr(game, "GameBin") != NULL
1.108 - && strstr(game, MMPATH) != NULL)
1.109 + && strstr(game, mmpath) != NULL)
1.110 {
1.111 fclose(op);
1.112 op = NULL;
1.113 break; /* Nothing more to do! */
1.114 } else {
1.115 - fputs("\t\t\t\tGameBin\t\t" MMPATH "\n", op);
1.116 + fputs("\t\t\tGameBin\t\t\t|gameinfo_path|", op);
1.117 + fputs(mmpath, op);
1.118 + fputs("\n", op);
1.119 ps = Parse_None;
1.120 }
1.121 }
1.122 @@ -135,7 +213,7 @@
1.123
1.124 if (!op)
1.125 {
1.126 - /* Well, we can't really do anything else. Give up. */
1.127 + /* Well, we can't really do anything else. Give up. */
1.128 fclose(fp);
1.129 return;
1.130 }