Separate DoneResearch for teams
parent
3479c51bb9
commit
79c131394d
|
@ -823,7 +823,7 @@ void CAutoFactory::UpdateInterface()
|
|||
void CAutoFactory::UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy)
|
||||
{
|
||||
EnableInterface(pw, event, !bBusy);
|
||||
DeadInterface(pw, event, m_main->CanFactory(ObjectTypeFromFactoryButton(event)));
|
||||
DeadInterface(pw, event, m_main->CanFactory(ObjectTypeFromFactoryButton(event), m_object->GetTeam()));
|
||||
}
|
||||
|
||||
// Plays the sound of the manipulator arm.
|
||||
|
|
|
@ -122,7 +122,7 @@ Error CAutoLabo::StartAction(int param)
|
|||
|
||||
m_research = static_cast<ResearchType>(param);
|
||||
|
||||
if ( m_main->IsResearchDone(m_research) )
|
||||
if ( m_main->IsResearchDone(m_research, m_object->GetTeam()) )
|
||||
{
|
||||
return ERR_LABO_ALREADY;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ bool CAutoLabo::EventProcess(const Event &event)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_main->MarkResearchDone(m_research); // research done
|
||||
m_main->MarkResearchDone(m_research, m_object->GetTeam()); // research done
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
UpdateInterface();
|
||||
|
@ -538,8 +538,8 @@ void CAutoLabo::OkayButton(Ui::CWindow *pw, EventType event)
|
|||
|
||||
bool CAutoLabo::TestResearch(EventType event)
|
||||
{
|
||||
if ( event == EVENT_OBJECT_RiPAW ) return m_main->IsResearchDone(RESEARCH_iPAW);
|
||||
if ( event == EVENT_OBJECT_RiGUN ) return m_main->IsResearchDone(RESEARCH_iGUN);
|
||||
if ( event == EVENT_OBJECT_RiPAW ) return m_main->IsResearchDone(RESEARCH_iPAW, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RiGUN ) return m_main->IsResearchDone(RESEARCH_iGUN, m_object->GetTeam());
|
||||
|
||||
return m_main;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ Error CAutoResearch::StartAction(int param)
|
|||
|
||||
m_research = static_cast<ResearchType>(param);
|
||||
|
||||
if ( m_main->IsResearchDone(m_research) )
|
||||
if ( m_main->IsResearchDone(m_research, m_object->GetTeam()) )
|
||||
{
|
||||
return ERR_RESEARCH_ALREADY;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ bool CAutoResearch::EventProcess(const Event &event)
|
|||
}
|
||||
else
|
||||
{
|
||||
m_main->MarkResearchDone(m_research); // research done
|
||||
m_main->MarkResearchDone(m_research, m_object->GetTeam()); // research done
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
UpdateInterface();
|
||||
|
@ -464,14 +464,14 @@ void CAutoResearch::OkayButton(Ui::CWindow *pw, EventType event)
|
|||
|
||||
bool CAutoResearch::TestResearch(EventType event)
|
||||
{
|
||||
if ( event == EVENT_OBJECT_RTANK ) return m_main->IsResearchDone(RESEARCH_TANK);
|
||||
if ( event == EVENT_OBJECT_RFLY ) return m_main->IsResearchDone(RESEARCH_FLY);
|
||||
if ( event == EVENT_OBJECT_RTHUMP ) return m_main->IsResearchDone(RESEARCH_THUMP);
|
||||
if ( event == EVENT_OBJECT_RCANON ) return m_main->IsResearchDone(RESEARCH_CANON);
|
||||
if ( event == EVENT_OBJECT_RTOWER ) return m_main->IsResearchDone(RESEARCH_TOWER);
|
||||
if ( event == EVENT_OBJECT_RPHAZER ) return m_main->IsResearchDone(RESEARCH_PHAZER);
|
||||
if ( event == EVENT_OBJECT_RSHIELD ) return m_main->IsResearchDone(RESEARCH_SHIELD);
|
||||
if ( event == EVENT_OBJECT_RATOMIC ) return m_main->IsResearchDone(RESEARCH_ATOMIC);
|
||||
if ( event == EVENT_OBJECT_RTANK ) return m_main->IsResearchDone(RESEARCH_TANK, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RFLY ) return m_main->IsResearchDone(RESEARCH_FLY, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RTHUMP ) return m_main->IsResearchDone(RESEARCH_THUMP, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RCANON ) return m_main->IsResearchDone(RESEARCH_CANON, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RTOWER ) return m_main->IsResearchDone(RESEARCH_TOWER, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RPHAZER ) return m_main->IsResearchDone(RESEARCH_PHAZER, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RSHIELD ) return m_main->IsResearchDone(RESEARCH_SHIELD, m_object->GetTeam());
|
||||
if ( event == EVENT_OBJECT_RATOMIC ) return m_main->IsResearchDone(RESEARCH_ATOMIC, m_object->GetTeam());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -573,7 +573,7 @@ bool CBrain::EventProcess(const Event &event)
|
|||
axeY *= 0.5f;
|
||||
}
|
||||
|
||||
if ( !m_main->IsResearchDone(RESEARCH_FLY) )
|
||||
if ( !m_main->IsResearchDone(RESEARCH_FLY, m_object->GetTeam()) )
|
||||
{
|
||||
axeZ = -1.0f; // tomb
|
||||
}
|
||||
|
@ -1540,72 +1540,72 @@ bool CBrain::CreateInterface(bool bSelect)
|
|||
pos.x = ox+sx*0.0f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+35, EVENT_OBJECT_BRESEARCH);
|
||||
DeadInterface(pw, EVENT_OBJECT_BRESEARCH, m_main->CanBuild(OBJECT_RESEARCH));
|
||||
DeadInterface(pw, EVENT_OBJECT_BRESEARCH, m_main->CanBuild(OBJECT_RESEARCH, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*0.9f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+32, EVENT_OBJECT_BFACTORY);
|
||||
DeadInterface(pw, EVENT_OBJECT_BFACTORY, m_main->CanBuild(OBJECT_FACTORY));
|
||||
DeadInterface(pw, EVENT_OBJECT_BFACTORY, m_main->CanBuild(OBJECT_FACTORY, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*1.8f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+34, EVENT_OBJECT_BCONVERT);
|
||||
DeadInterface(pw, EVENT_OBJECT_BCONVERT, m_main->CanBuild(OBJECT_CONVERT));
|
||||
DeadInterface(pw, EVENT_OBJECT_BCONVERT, m_main->CanBuild(OBJECT_CONVERT, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*2.7f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+36, EVENT_OBJECT_BSTATION);
|
||||
DeadInterface(pw, EVENT_OBJECT_BSTATION, m_main->CanBuild(OBJECT_STATION));
|
||||
DeadInterface(pw, EVENT_OBJECT_BSTATION, m_main->CanBuild(OBJECT_STATION, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*3.6f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+40, EVENT_OBJECT_BRADAR);
|
||||
DeadInterface(pw, EVENT_OBJECT_BRADAR, m_main->CanBuild(OBJECT_RADAR));
|
||||
DeadInterface(pw, EVENT_OBJECT_BRADAR, m_main->CanBuild(OBJECT_RADAR, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*4.5f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BREPAIR);
|
||||
DeadInterface(pw, EVENT_OBJECT_BREPAIR, m_main->CanBuild(OBJECT_REPAIR));
|
||||
DeadInterface(pw, EVENT_OBJECT_BREPAIR, m_main->CanBuild(OBJECT_REPAIR, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*5.4f;
|
||||
pos.y = oy+sy*1.0f;
|
||||
pw->CreateButton(pos, ddim, 128+44, EVENT_OBJECT_BINFO);
|
||||
DeadInterface(pw, EVENT_OBJECT_BINFO, m_main->CanBuild(OBJECT_INFO));
|
||||
DeadInterface(pw, EVENT_OBJECT_BINFO, m_main->CanBuild(OBJECT_INFO, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*0.0f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+37, EVENT_OBJECT_BTOWER);
|
||||
DeadInterface(pw, EVENT_OBJECT_BTOWER, m_main->CanBuild(OBJECT_TOWER));
|
||||
DeadInterface(pw, EVENT_OBJECT_BTOWER, m_main->CanBuild(OBJECT_TOWER, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*0.9f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+39, EVENT_OBJECT_BENERGY);
|
||||
DeadInterface(pw, EVENT_OBJECT_BENERGY, m_main->CanBuild(OBJECT_ENERGY));
|
||||
DeadInterface(pw, EVENT_OBJECT_BENERGY, m_main->CanBuild(OBJECT_ENERGY, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*1.8f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+33, EVENT_OBJECT_BDERRICK);
|
||||
DeadInterface(pw, EVENT_OBJECT_BDERRICK, m_main->CanBuild(OBJECT_DERRICK));
|
||||
DeadInterface(pw, EVENT_OBJECT_BDERRICK, m_main->CanBuild(OBJECT_DERRICK, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*2.7f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+42, EVENT_OBJECT_BNUCLEAR);
|
||||
DeadInterface(pw, EVENT_OBJECT_BNUCLEAR, m_main->CanBuild(OBJECT_NUCLEAR));
|
||||
DeadInterface(pw, EVENT_OBJECT_BNUCLEAR, m_main->CanBuild(OBJECT_NUCLEAR, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*3.6f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+38, EVENT_OBJECT_BLABO);
|
||||
DeadInterface(pw, EVENT_OBJECT_BLABO, m_main->CanBuild(OBJECT_LABO));
|
||||
DeadInterface(pw, EVENT_OBJECT_BLABO, m_main->CanBuild(OBJECT_LABO, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*4.5f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+46, EVENT_OBJECT_BPARA);
|
||||
DeadInterface(pw, EVENT_OBJECT_BPARA, m_main->CanBuild(OBJECT_PARA));
|
||||
DeadInterface(pw, EVENT_OBJECT_BPARA, m_main->CanBuild(OBJECT_PARA, m_object->GetTeam()));
|
||||
|
||||
pos.x = ox+sx*5.4f;
|
||||
pos.y = oy+sy*0.1f;
|
||||
pw->CreateButton(pos, ddim, 128+41, EVENT_OBJECT_BDESTROYER);
|
||||
DeadInterface(pw, EVENT_OBJECT_BDESTROYER, m_main->CanBuild(OBJECT_DESTROYER));
|
||||
DeadInterface(pw, EVENT_OBJECT_BDESTROYER, m_main->CanBuild(OBJECT_DESTROYER, m_object->GetTeam()));
|
||||
|
||||
if ( m_main->IsBuildingEnabled(BUILD_GFLAT) )
|
||||
{
|
||||
|
@ -2403,8 +2403,8 @@ void CBrain::UpdateInterface()
|
|||
}
|
||||
else
|
||||
{
|
||||
DeadInterface(pw, EVENT_OBJECT_GASUP, m_main->IsResearchDone(RESEARCH_FLY));
|
||||
DeadInterface(pw, EVENT_OBJECT_GASDOWN, m_main->IsResearchDone(RESEARCH_FLY));
|
||||
DeadInterface(pw, EVENT_OBJECT_GASUP, m_main->IsResearchDone(RESEARCH_FLY, m_object->GetTeam()));
|
||||
DeadInterface(pw, EVENT_OBJECT_GASDOWN, m_main->IsResearchDone(RESEARCH_FLY, m_object->GetTeam()));
|
||||
}
|
||||
|
||||
if ( type == OBJECT_HUMAN ||
|
||||
|
|
|
@ -229,7 +229,8 @@ CRobotMain::CRobotMain(CController* controller)
|
|||
m_cameraZoom = 0.0f;
|
||||
|
||||
m_build = 0;
|
||||
m_researchDone = 0; // no research done
|
||||
m_researchDone.clear(); // no research done
|
||||
m_researchDone[0] = 0;
|
||||
m_researchEnable = 0;
|
||||
g_unit = UNIT;
|
||||
|
||||
|
@ -1121,7 +1122,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
|
||||
if (strcmp(cmd, "fly") == 0)
|
||||
{
|
||||
m_researchDone |= RESEARCH_FLY;
|
||||
m_researchDone[0] |= RESEARCH_FLY;
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
return;
|
||||
|
@ -1129,7 +1130,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
|
||||
if (strcmp(cmd, "allresearch") == 0)
|
||||
{
|
||||
m_researchDone = -1; // all research are done
|
||||
m_researchDone[0] = -1; // all research are done
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
return;
|
||||
|
@ -1145,7 +1146,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
|
||||
if (strcmp(cmd, "all") == 0)
|
||||
{
|
||||
m_researchDone = -1; // all research are done
|
||||
m_researchDone[0] = -1; // all research are done
|
||||
m_build = -1; // all buildings are available
|
||||
|
||||
m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
|
@ -2894,7 +2895,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
if (!resetObject)
|
||||
{
|
||||
m_build = 0;
|
||||
m_researchDone = 0; // no research done
|
||||
m_researchDone.clear(); // no research done
|
||||
m_researchDone[0] = 0;
|
||||
m_researchEnable = 0;
|
||||
|
||||
FlushDisplayInfo();
|
||||
|
@ -3886,7 +3888,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
if (line->GetCommand() == "DoneResearch" && read[0] == 0 && !resetObject) // not loading file?
|
||||
{
|
||||
m_researchDone |= line->GetParam("type")->AsResearchFlag();
|
||||
m_researchDone[0] |= line->GetParam("type")->AsResearchFlag();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3910,7 +3912,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
if (strcmp(base, "freemissions") == 0 && !resetObject) // free play?
|
||||
{
|
||||
m_researchDone = m_freeResearch;
|
||||
m_researchDone[0] = m_freeResearch;
|
||||
|
||||
m_build = m_freeBuild;
|
||||
m_build &= ~BUILD_RESEARCH;
|
||||
|
@ -4936,7 +4938,7 @@ bool CRobotMain::IOWriteScene(const char *filename, const char *filecbot, char *
|
|||
levelParser.AddLine(std::move(line));
|
||||
|
||||
line.reset(new CLevelParserLine("DoneResearch"));
|
||||
line->AddParam("bits", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_researchDone))});
|
||||
line->AddParam("bits", CLevelParserParamUPtr{new CLevelParserParam(static_cast<int>(m_researchDone[0]))});
|
||||
levelParser.AddLine(std::move(line));
|
||||
|
||||
float sleep, delay, magnetic, progress;
|
||||
|
@ -5128,7 +5130,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
|||
m_map->ZoomMap(line->GetParam("zoom")->AsFloat());
|
||||
|
||||
if (line->GetCommand() == "DoneResearch")
|
||||
m_researchDone = line->GetParam("bits")->AsInt();
|
||||
m_researchDone[0] = line->GetParam("bits")->AsInt();
|
||||
|
||||
if (line->GetCommand() == "BlitzMode")
|
||||
{
|
||||
|
@ -5246,7 +5248,7 @@ CObject* CRobotMain::IOReadScene(const char *filename, const char *filecbot)
|
|||
//! Writes the global parameters for free play
|
||||
void CRobotMain::WriteFreeParam()
|
||||
{
|
||||
m_freeResearch |= m_researchDone;
|
||||
m_freeResearch |= m_researchDone[0];
|
||||
m_freeBuild |= m_build;
|
||||
|
||||
if (m_gamerName == "") return;
|
||||
|
@ -5574,7 +5576,7 @@ Error CRobotMain::CheckEndMission(bool frame)
|
|||
{
|
||||
if (m_endTakeResearch != 0)
|
||||
{
|
||||
if (m_endTakeResearch != (m_endTakeResearch&m_researchDone))
|
||||
if (m_endTakeResearch != (m_endTakeResearch&m_researchDone[0]))
|
||||
{
|
||||
m_missionResult = ERR_MISSION_NOTERM;
|
||||
}
|
||||
|
@ -6244,14 +6246,14 @@ void CRobotMain::SetEnableResearch(int enableResearch)
|
|||
m_researchEnable = enableResearch;
|
||||
}
|
||||
|
||||
int CRobotMain::GetDoneResearch()
|
||||
int CRobotMain::GetDoneResearch(int team)
|
||||
{
|
||||
return m_researchDone;
|
||||
return m_researchDone[team];
|
||||
}
|
||||
|
||||
void CRobotMain::SetDoneResearch(int doneResearch)
|
||||
void CRobotMain::SetDoneResearch(int doneResearch, int team)
|
||||
{
|
||||
m_researchDone = doneResearch;
|
||||
m_researchDone[team] = doneResearch;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6285,56 +6287,72 @@ bool CRobotMain::IsResearchEnabled(ResearchType type)
|
|||
return (m_researchEnable & type) != 0;
|
||||
}
|
||||
|
||||
bool CRobotMain::IsResearchDone(ResearchType type)
|
||||
bool CRobotMain::IsResearchDone(ResearchType type, int team)
|
||||
{
|
||||
return (m_researchDone & type) != 0;
|
||||
if(team != 0 && m_researchDone.count(team) == 0)
|
||||
{
|
||||
// Initialize with defaults
|
||||
m_researchDone[team] = m_researchDone[0];
|
||||
}
|
||||
|
||||
return (m_researchDone[team] & type) != 0;
|
||||
}
|
||||
|
||||
void CRobotMain::MarkResearchDone(ResearchType type)
|
||||
void CRobotMain::MarkResearchDone(ResearchType type, int team)
|
||||
{
|
||||
m_researchDone |= type;
|
||||
WriteFreeParam();
|
||||
if(team != 0 && m_researchDone.count(team) == 0)
|
||||
{
|
||||
// Initialize with defaults
|
||||
m_researchDone[team] = m_researchDone[0];
|
||||
}
|
||||
|
||||
m_researchDone[team] |= type;
|
||||
|
||||
if(team == 0)
|
||||
{
|
||||
WriteFreeParam();
|
||||
}
|
||||
}
|
||||
|
||||
Error CRobotMain::CanBuildError(ObjectType type)
|
||||
Error CRobotMain::CanBuildError(ObjectType type, int team)
|
||||
{
|
||||
if(!IsBuildingEnabled(type)) return ERR_BUILD_DISABLED;
|
||||
|
||||
if(type == OBJECT_TOWER && !IsResearchDone(RESEARCH_TOWER)) return ERR_BUILD_RESEARCH;
|
||||
if(type == OBJECT_ATOMIC && !IsResearchDone(RESEARCH_ATOMIC)) return ERR_BUILD_RESEARCH;
|
||||
if(type == OBJECT_TOWER && !IsResearchDone(RESEARCH_TOWER, team)) return ERR_BUILD_RESEARCH;
|
||||
if(type == OBJECT_ATOMIC && !IsResearchDone(RESEARCH_ATOMIC, team)) return ERR_BUILD_RESEARCH;
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
bool CRobotMain::CanBuild(ObjectType type)
|
||||
bool CRobotMain::CanBuild(ObjectType type, int team)
|
||||
{
|
||||
return CanBuildError(type) == ERR_OK;
|
||||
return CanBuildError(type, team) == ERR_OK;
|
||||
}
|
||||
|
||||
Error CRobotMain::CanFactoryError(ObjectType type)
|
||||
Error CRobotMain::CanFactoryError(ObjectType type, int team)
|
||||
{
|
||||
ToolType tool = GetToolFromObject(type);
|
||||
DriveType drive = GetDriveFromObject(type);
|
||||
|
||||
if (tool == ToolType::Sniffer && !IsResearchDone(RESEARCH_SNIFFER) ) return ERR_BUILD_RESEARCH;
|
||||
if (tool == ToolType::Shooter && !IsResearchDone(RESEARCH_CANON) ) return ERR_BUILD_RESEARCH;
|
||||
if (tool == ToolType::OrganicShooter && !IsResearchDone(RESEARCH_iGUN) ) return ERR_BUILD_RESEARCH;
|
||||
if (tool == ToolType::Sniffer && !IsResearchDone(RESEARCH_SNIFFER, team)) return ERR_BUILD_RESEARCH;
|
||||
if (tool == ToolType::Shooter && !IsResearchDone(RESEARCH_CANON, team)) return ERR_BUILD_RESEARCH;
|
||||
if (tool == ToolType::OrganicShooter && !IsResearchDone(RESEARCH_iGUN, team)) return ERR_BUILD_RESEARCH;
|
||||
|
||||
if (drive == DriveType::Tracked && !IsResearchDone(RESEARCH_TANK) ) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::Winged && !IsResearchDone(RESEARCH_FLY) ) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::Legged && !IsResearchDone(RESEARCH_iPAW) ) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::BigTracked && !IsResearchDone(RESEARCH_TANK) ) return ERR_BUILD_RESEARCH; // NOTE: Subber is not BigTracked! It currently counts as Other
|
||||
if (drive == DriveType::Tracked && !IsResearchDone(RESEARCH_TANK, team)) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::Winged && !IsResearchDone(RESEARCH_FLY, team)) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::Legged && !IsResearchDone(RESEARCH_iPAW, team)) return ERR_BUILD_RESEARCH;
|
||||
if (drive == DriveType::BigTracked && !IsResearchDone(RESEARCH_TANK, team)) return ERR_BUILD_RESEARCH; // NOTE: Subber is not BigTracked! It currently counts as Other
|
||||
|
||||
if (type == OBJECT_MOBILErt && !IsResearchDone(RESEARCH_THUMP) ) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErc && !IsResearchDone(RESEARCH_PHAZER) ) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErr && !IsResearchDone(RESEARCH_RECYCLER)) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErs && !IsResearchDone(RESEARCH_SHIELD) ) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILEsa && !IsResearchDone(RESEARCH_SUBM) ) return ERR_BUILD_DISABLED; // Can be only researched manually in Scene file
|
||||
if (type == OBJECT_MOBILErt && !IsResearchDone(RESEARCH_THUMP, team)) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErc && !IsResearchDone(RESEARCH_PHAZER, team)) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErr && !IsResearchDone(RESEARCH_RECYCLER, team)) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILErs && !IsResearchDone(RESEARCH_SHIELD, team)) return ERR_BUILD_RESEARCH;
|
||||
if (type == OBJECT_MOBILEsa && !IsResearchDone(RESEARCH_SUBM, team)) return ERR_BUILD_DISABLED; // Can be only researched manually in Scene file
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
bool CRobotMain::CanFactory(ObjectType type)
|
||||
bool CRobotMain::CanFactory(ObjectType type, int team)
|
||||
{
|
||||
return CanFactoryError(type) == ERR_OK;
|
||||
return CanFactoryError(type, team) == ERR_OK;
|
||||
}
|
||||
|
|
|
@ -343,8 +343,8 @@ public:
|
|||
//@}
|
||||
//! Get/set done researches
|
||||
//@{
|
||||
int GetDoneResearch();
|
||||
void SetDoneResearch(int doneResearch);
|
||||
int GetDoneResearch(int team);
|
||||
void SetDoneResearch(int doneResearch, int team);
|
||||
//@}
|
||||
|
||||
//! Returns true if the given building is enabled
|
||||
|
@ -355,20 +355,20 @@ public:
|
|||
//! Returns true if the given research is enabled
|
||||
bool IsResearchEnabled(ResearchType type);
|
||||
//! Returns true if the given research is done
|
||||
bool IsResearchDone(ResearchType type);
|
||||
bool IsResearchDone(ResearchType type, int team);
|
||||
//! Marks research as done
|
||||
void MarkResearchDone(ResearchType type);
|
||||
void MarkResearchDone(ResearchType type, int team);
|
||||
|
||||
//! Retruns true if all requirements to build this object are met (EnableBuild + DoneResearch)
|
||||
//@{
|
||||
bool CanBuild(ObjectType type);
|
||||
Error CanBuildError(ObjectType type);
|
||||
bool CanBuild(ObjectType type, int team);
|
||||
Error CanBuildError(ObjectType type, int team);
|
||||
//@}
|
||||
|
||||
//! Retruns true if all requirements to create this object in BotFactory are met (DoneResearch)
|
||||
//@{
|
||||
bool CanFactory(ObjectType type);
|
||||
Error CanFactoryError(ObjectType type);
|
||||
bool CanFactory(ObjectType type, int team);
|
||||
Error CanFactoryError(ObjectType type, int team);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
|
@ -548,12 +548,17 @@ protected:
|
|||
|
||||
std::string m_gamerName;
|
||||
|
||||
int m_build; // constructible buildings
|
||||
int m_researchDone; // research done
|
||||
long m_researchEnable; // research available
|
||||
//! Enabled buildings
|
||||
int m_build;
|
||||
//! Available researches
|
||||
long m_researchEnable;
|
||||
//! Done researches for each team
|
||||
std::map<int, int> m_researchDone;
|
||||
|
||||
int m_freeBuild; // constructible buildings
|
||||
int m_freeResearch; // researches possible
|
||||
//! Buildings unlocked for free game
|
||||
int m_freeBuild;
|
||||
//! Researches unlocked for free game
|
||||
int m_freeResearch;
|
||||
|
||||
Error m_missionResult;
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ bool CScriptFunctions::rGetResearchEnable(CBotVar* var, CBotVar* result, int& ex
|
|||
|
||||
bool CScriptFunctions::rGetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
result->SetValInt(CRobotMain::GetInstancePointer()->GetDoneResearch());
|
||||
result->SetValInt(CRobotMain::GetInstancePointer()->GetDoneResearch(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ bool CScriptFunctions::rSetResearchEnable(CBotVar* var, CBotVar* result, int& ex
|
|||
|
||||
bool CScriptFunctions::rSetResearchDone(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
CRobotMain::GetInstancePointer()->SetDoneResearch(var->GetValInt());
|
||||
CRobotMain::GetInstancePointer()->SetDoneResearch(var->GetValInt(), 0);
|
||||
CApplication::GetInstancePointer()->GetEventQueue()->AddEvent(Event(EVENT_UPDINTERFACE));
|
||||
return true;
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul
|
|||
return false;
|
||||
}
|
||||
|
||||
err = CRobotMain::GetInstancePointer()->CanFactoryError(type);
|
||||
err = CRobotMain::GetInstancePointer()->CanFactoryError(type, factory->GetTeam());
|
||||
|
||||
if ( err == ERR_OK )
|
||||
{
|
||||
|
@ -1391,10 +1391,11 @@ CBotTypResult CScriptFunctions::cCanBuild(CBotVar* &var, void* user)
|
|||
|
||||
bool CScriptFunctions::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
CObject* pThis = static_cast<CObject *>(user);
|
||||
ObjectType category = static_cast<ObjectType>(var->GetValInt()); //get category parameter
|
||||
exception = 0;
|
||||
|
||||
result->SetValInt(CRobotMain::GetInstancePointer()->CanBuild(category));
|
||||
result->SetValInt(CRobotMain::GetInstancePointer()->CanBuild(category, pThis->GetTeam()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1403,8 +1404,8 @@ bool CScriptFunctions::rCanBuild(CBotVar* var, CBotVar* result, int& exception,
|
|||
|
||||
bool CScriptFunctions::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
|
||||
{
|
||||
CScript* script = (static_cast<CObject *>(user))->GetRunScript();
|
||||
CObject* pThis = static_cast<CObject *>(user);
|
||||
CScript* script = pThis->GetRunScript();
|
||||
ObjectType oType;
|
||||
ObjectType category;
|
||||
Error err;
|
||||
|
@ -1425,7 +1426,7 @@ bool CScriptFunctions::rBuild(CBotVar* var, CBotVar* result, int& exception, voi
|
|||
else
|
||||
{
|
||||
category = static_cast<ObjectType>(var->GetValInt()); // get category parameter
|
||||
err = CRobotMain::GetInstancePointer()->CanBuildError(category);
|
||||
err = CRobotMain::GetInstancePointer()->CanBuildError(category, pThis->GetTeam());
|
||||
|
||||
if (pThis->GetIgnoreBuildCheck())
|
||||
err = ERR_OK;
|
||||
|
|
Loading…
Reference in New Issue