140 return result; |
140 return result; |
141 } |
141 } |
142 |
142 |
143 static uint32_t buildModFlags(const flib_scheme *scheme) { |
143 static uint32_t buildModFlags(const flib_scheme *scheme) { |
144 uint32_t result = 0; |
144 uint32_t result = 0; |
145 for(int i=0; i<scheme->meta->modCount; i++) { |
145 for(int i=0; i<flib_meta.modCount; i++) { |
146 if(scheme->mods[i]) { |
146 if(scheme->mods[i]) { |
147 int bitmaskIndex = scheme->meta->mods[i].bitmaskIndex; |
147 int bitmaskIndex = flib_meta.mods[i].bitmaskIndex; |
148 result |= (UINT32_C(1) << bitmaskIndex); |
148 result |= (UINT32_C(1) << bitmaskIndex); |
149 } |
149 } |
150 } |
150 } |
151 return result; |
151 return result; |
152 } |
152 } |
153 |
153 |
154 int flib_ipc_append_gamescheme(flib_vector *vec, const flib_scheme *scheme) { |
154 int flib_ipc_append_gamescheme(flib_vector *vec, const flib_scheme *scheme) { |
155 int result = -1; |
155 int result = -1; |
156 flib_vector *tempvector = flib_vector_create(); |
156 flib_vector *tempvector = flib_vector_create(); |
157 if(!log_badargs_if2(vec==NULL, scheme==NULL) && tempvector) { |
157 if(!log_badargs_if2(vec==NULL, scheme==NULL) && tempvector) { |
158 const flib_metascheme *meta = scheme->meta; |
|
159 bool error = false; |
158 bool error = false; |
160 error |= flib_ipc_append_message(tempvector, "e$gmflags %"PRIu32, buildModFlags(scheme)); |
159 error |= flib_ipc_append_message(tempvector, "e$gmflags %"PRIu32, buildModFlags(scheme)); |
161 for(int i=0; i<meta->settingCount; i++) { |
160 for(int i=0; i<flib_meta.settingCount; i++) { |
162 if(meta->settings[i].engineCommand) { |
161 if(flib_meta.settings[i].engineCommand) { |
163 int value = scheme->settings[i]; |
162 int value = scheme->settings[i]; |
164 if(meta->settings[i].maxMeansInfinity) { |
163 if(flib_meta.settings[i].maxMeansInfinity) { |
165 value = value>=meta->settings[i].max ? 9999 : value; |
164 value = value>=flib_meta.settings[i].max ? 9999 : value; |
166 } |
165 } |
167 if(meta->settings[i].times1000) { |
166 if(flib_meta.settings[i].times1000) { |
168 value *= 1000; |
167 value *= 1000; |
169 } |
168 } |
170 error |= flib_ipc_append_message(tempvector, "%s %i", meta->settings[i].engineCommand, value); |
169 error |= flib_ipc_append_message(tempvector, "%s %i", flib_meta.settings[i].engineCommand, value); |
171 } |
170 } |
172 } |
171 } |
173 |
172 |
174 if(!error) { |
173 if(!error) { |
175 // Message created, now we can copy everything. |
174 // Message created, now we can copy everything. |