MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / setResearch

Method setResearch

game/state/city/research.cpp:249–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249void Lab::setResearch(StateRef<Lab> lab, StateRef<ResearchTopic> topic, sp<GameState> state)
250{
251 if (topic)
252 {
253 if (topic->current_lab)
254 {
255 LogAssert(topic->current_lab->current_project == topic);
256 // FIXME: What was the purpose of this? There should be no way to cancel research by
257 // selecting it! Commenting for now
258 /*
259 topic->current_lab->current_project = "";
260 topic->current_lab = "";
261 */
262 return;
263 }
264 if (lab->current_project == topic)
265 {
266 return;
267 }
268 }
269 if (lab->current_project)
270 {
271 // Refund if haven't started working on the manufacturing topic
272 if (lab->type == ResearchTopic::Type::Engineering &&
273 lab->manufacture_man_hours_invested == 0)
274 {
275 state->player->balance += lab->current_project->cost;
276 }
277 lab->current_project->current_lab = "";
278 lab->manufacture_man_hours_invested = 0;
279 lab->manufacture_done = 0;
280 lab->manufacture_goal = 0;
281 }
282 lab->current_project = topic;
283 if (topic)
284 {
285 LogAssert(!(topic->required_lab_size == ResearchTopic::LabSize::Large &&
286 lab->size == ResearchTopic::LabSize::Small));
287
288 switch (lab->type)
289 {
290 case ResearchTopic::Type::BioChem:
291 case ResearchTopic::Type::Physics:
292 topic->current_lab = lab;
293 if (!topic->started)
294 {
295 StateRef<Base> thisBase;
296 for (auto &base : state->player_bases)
297 {
298 for (auto &facility : base.second->facilities)
299 {
300 if (facility->lab == lab)
301 {
302 thisBase = {state.get(), base.first};
303 break;
304 }
305 }
306 if (thisBase)

Callers

nothing calls this directly

Calls 2

consumeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected