1.1 --- a/core/systems/PluginInfoDatabase.cpp Tue Oct 30 20:43:59 2007 +0000
1.2 +++ b/core/systems/PluginInfoDatabase.cpp Wed Oct 31 05:04:07 2007 +0000
1.3 @@ -82,7 +82,7 @@
1.4 m_infodb = -1;
1.5 }
1.6
1.7 -SMCParseResult CPluginInfoDatabase::MakeError(const char *fmt, ...)
1.8 +SMCResult CPluginInfoDatabase::MakeError(const char *fmt, ...)
1.9 {
1.10 char buffer[512];
1.11 va_list ap;
1.12 @@ -93,7 +93,7 @@
1.13
1.14 m_errmsg = m_strtab->AddString(buffer);
1.15
1.16 - return SMCParse_HaltFail;
1.17 + return SMCResult_HaltFail;
1.18 }
1.19
1.20 unsigned int CPluginInfoDatabase::GetSettingsNum()
1.21 @@ -149,10 +149,7 @@
1.22 *val = m_strtab->GetString(table[opt_num].val);
1.23 }
1.24
1.25 -SMCParseResult CPluginInfoDatabase::ReadSMC_KeyValue(const char *key,
1.26 - const char *value,
1.27 - bool key_quotes,
1.28 - bool value_quotes)
1.29 +SMCResult CPluginInfoDatabase::ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value)
1.30 {
1.31 if (cur_plugin != -1)
1.32 {
1.33 @@ -164,28 +161,46 @@
1.34 if (strcasecmp(value, "yes") == 0)
1.35 {
1.36 plugin->pause_val = true;
1.37 - } else {
1.38 + }
1.39 + else
1.40 + {
1.41 plugin->pause_val = false;
1.42 }
1.43 - } else if (strcmp(key, "lifetime") == 0) {
1.44 + }
1.45 + else if (strcmp(key, "lifetime") == 0)
1.46 + {
1.47 if (strcasecmp(value, "private") == 0)
1.48 {
1.49 plugin->type_val = PluginType_Private;
1.50 - } else if (strcasecmp(value, "mapsync") == 0) {
1.51 + }
1.52 + else if (strcasecmp(value, "mapsync") == 0)
1.53 + {
1.54 plugin->type_val = PluginType_MapUpdated;
1.55 - } else if (strcasecmp(value, "maponly") == 0) {
1.56 + }
1.57 + else if (strcasecmp(value, "maponly") == 0)
1.58 + {
1.59 plugin->type_val = PluginType_MapOnly;
1.60 - } else if (strcasecmp(value, "global") == 0) {
1.61 + }
1.62 + else if (strcasecmp(value, "global") == 0)
1.63 + {
1.64 plugin->type_val = PluginType_Global;
1.65 - } else {
1.66 + }
1.67 + else
1.68 + {
1.69 return MakeError("Unknown value for key \"lifetime\": \"%s\"", value);
1.70 }
1.71 - } else if (strcmp(key, "blockload") == 0) {
1.72 + }
1.73 + else if (strcmp(key, "blockload") == 0)
1.74 + {
1.75 plugin->blockload_val = true;
1.76 - } else {
1.77 + }
1.78 + else
1.79 + {
1.80 return MakeError("Unknown property key: \"%s\"", key);
1.81 }
1.82 - } else {
1.83 + }
1.84 + else
1.85 + {
1.86 /* Cache every option, valid or not */
1.87 int keyidx = m_strtab->AddString(key);
1.88 int validx = m_strtab->AddString(value);
1.89 @@ -199,7 +214,9 @@
1.90 {
1.91 //right now we don't have many
1.92 plugin->opts_size = 2;
1.93 - } else {
1.94 + }
1.95 + else
1.96 + {
1.97 plugin->opts_size *= 2;
1.98 }
1.99 int newidx = memtab->CreateMem(plugin->opts_size * sizeof(PluginOpts), (void **)&table);
1.100 @@ -211,23 +228,29 @@
1.101 memcpy(table, oldtable, oldsize * sizeof(PluginOpts));
1.102 }
1.103 plugin->optarray = newidx;
1.104 - } else {
1.105 + }
1.106 + else
1.107 + {
1.108 table = (PluginOpts *)memtab->GetAddress(plugin->optarray);
1.109 }
1.110 PluginOpts *opt = &table[plugin->opts_num++];
1.111 opt->key = keyidx;
1.112 opt->val = validx;
1.113 }
1.114 - } else if (in_plugins) {
1.115 + }
1.116 + else if (in_plugins)
1.117 + {
1.118 return MakeError("Unknown property key: \"%s\"", key);
1.119 - } else {
1.120 + }
1.121 + else
1.122 + {
1.123 /* Ignore anything we don't know about! */
1.124 }
1.125
1.126 - return SMCParse_Continue;
1.127 + return SMCResult_Continue;
1.128 }
1.129
1.130 -SMCParseResult CPluginInfoDatabase::ReadSMC_LeavingSection()
1.131 +SMCResult CPluginInfoDatabase::ReadSMC_LeavingSection(const SMCStates *states)
1.132 {
1.133 if (in_plugins)
1.134 {
1.135 @@ -236,7 +259,9 @@
1.136 if (in_options)
1.137 {
1.138 in_options = false;
1.139 - } else {
1.140 + }
1.141 + else
1.142 + {
1.143 /* If the plugin is ending, add it to the table */
1.144 BaseMemTable *memtab = m_strtab->GetMemTable();
1.145 int *table;
1.146 @@ -246,7 +271,9 @@
1.147 if (!m_infodb_size)
1.148 {
1.149 m_infodb_size = 8;
1.150 - } else {
1.151 + }
1.152 + else
1.153 + {
1.154 m_infodb_size *= 2;
1.155 }
1.156 int newidx = memtab->CreateMem(m_infodb_size, (void **)&table);
1.157 @@ -256,22 +283,26 @@
1.158 memcpy(table, oldtable, oldsize * sizeof(int));
1.159 }
1.160 m_infodb = newidx;
1.161 - } else {
1.162 + }
1.163 + else
1.164 + {
1.165 table = (int *)memtab->GetAddress(m_infodb);
1.166 }
1.167 /* Assign to table and scrap the current plugin */
1.168 table[m_infodb_count++] = cur_plugin;
1.169 cur_plugin = -1;
1.170 }
1.171 - } else {
1.172 + }
1.173 + else
1.174 + {
1.175 in_plugins = false;
1.176 }
1.177 }
1.178
1.179 - return SMCParse_Continue;
1.180 + return SMCResult_Continue;
1.181 }
1.182
1.183 -SMCParseResult CPluginInfoDatabase::ReadSMC_NewSection(const char *name, bool opt_quotes)
1.184 +SMCResult CPluginInfoDatabase::ReadSMC_NewSection(const SMCStates *states, const char *name)
1.185 {
1.186 if (!in_plugins)
1.187 {
1.188 @@ -279,13 +310,17 @@
1.189 if (strcmp(name, "Plugins") != 0)
1.190 {
1.191 return MakeError("Unknown root section: \"%s\"", name);
1.192 - } else {
1.193 + }
1.194 + else
1.195 + {
1.196 /* Otherwise set our states */
1.197 in_plugins = true;
1.198 cur_plugin = -1;
1.199 in_options = false;
1.200 }
1.201 - } else {
1.202 + }
1.203 + else
1.204 + {
1.205 if (cur_plugin == -1)
1.206 {
1.207 /* If we get a plugin node and we don't have a current plugin, create a new one */
1.208 @@ -295,15 +330,20 @@
1.209 plugin->Init();
1.210 plugin->name = i_name;
1.211 in_options = false;
1.212 - } else {
1.213 + }
1.214 + else
1.215 + {
1.216 if (!in_options && strcmp(name, "Options") == 0)
1.217 {
1.218 in_options = true;
1.219 - } else {
1.220 + }
1.221 + else
1.222 + {
1.223 return MakeError("Unknown plugin sub-section: \"%s\"", name);
1.224 }
1.225 }
1.226 }
1.227
1.228 - return SMCParse_Continue;
1.229 + return SMCResult_Continue;
1.230 }
1.231 +