switched resourcemultiplier to int (using the index now) and added some debug output for testing.
This commit is contained in:
parent
b102ef513c
commit
ede8977aff
|
@ -36,7 +36,7 @@ private:
|
|||
string networkPlayerNames[GameConstants::maxPlayers];
|
||||
|
||||
ControlType factionControls[GameConstants::maxPlayers];
|
||||
float resourceMultiplier[GameConstants::maxPlayers];
|
||||
int resourceMultiplierIndex[GameConstants::maxPlayers];
|
||||
|
||||
int thisFactionIndex;
|
||||
int factionCount;
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
factionTypeNames[i] = "";
|
||||
networkPlayerNames[i] = "";
|
||||
factionControls[i] = ctClosed;
|
||||
resourceMultiplier[i] = 1.0f;
|
||||
resourceMultiplierIndex[i] = 1.0f;
|
||||
teams[i] = 0;
|
||||
startLocationIndex[i] = i;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
return result;
|
||||
}
|
||||
ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];}
|
||||
float getResourceMultiplier(int factionIndex) const {return resourceMultiplier[factionIndex];}
|
||||
int getResourceMultiplierIndex(int factionIndex) const {return resourceMultiplierIndex[factionIndex];}
|
||||
|
||||
bool isNetworkGame() const {
|
||||
bool result = false;
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
void setFactionTypeName(int factionIndex, const string& factionTypeName) {this->factionTypeNames[factionIndex]= factionTypeName;}
|
||||
void setNetworkPlayerName(int factionIndex,const string& playername) {this->networkPlayerNames[factionIndex]= playername;}
|
||||
void setFactionControl(int factionIndex, ControlType controller) {this->factionControls[factionIndex]= controller;}
|
||||
void setResourceMultiplier(int factionIndex, float multiplier) {this->resourceMultiplier[factionIndex]= multiplier;}
|
||||
void setResourceMultiplierIndex(int factionIndex, int multiplierIndex) {this->resourceMultiplierIndex[factionIndex]= multiplierIndex;}
|
||||
|
||||
void setThisFactionIndex(int thisFactionIndex) {this->thisFactionIndex= thisFactionIndex;}
|
||||
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
||||
|
@ -180,7 +180,7 @@ public:
|
|||
result += "networkPlayerName = " + networkPlayerNames[idx] + "\n";
|
||||
|
||||
result += "factionControl = " + intToStr(factionControls[idx]) + "\n";
|
||||
result += "resourceMultiplier = " + intToStr(resourceMultiplier[idx]) + "\n";
|
||||
result += "resourceMultiplierIndex = " + intToStr(resourceMultiplierIndex[idx]) + "\n";
|
||||
result += "team = " + intToStr(teams[idx]) + "\n";
|
||||
result += "startLocationIndex = " + intToStr(startLocationIndex[idx]) + "\n";
|
||||
}
|
||||
|
|
|
@ -68,7 +68,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
lastSetChangedGameSettings = time(NULL);
|
||||
showFullConsole=false;
|
||||
|
||||
rMultiplierOffset=0.5f;
|
||||
|
||||
currentFactionName="";
|
||||
currentMap="";
|
||||
|
@ -321,7 +320,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
controlItems.push_back(lang.get("Human"));
|
||||
|
||||
for(int i=0; i<45; ++i){
|
||||
rMultiplier.push_back(floatToStr(rMultiplierOffset+0.1f*i));
|
||||
rMultiplier.push_back(intToStr(0.5f+0.1f*i));
|
||||
}
|
||||
|
||||
if(config.getBool("EnableNetworkCpu","false") == true) {
|
||||
|
@ -1006,7 +1005,7 @@ void MenuStateConnectedGame::update() {
|
|||
for(int i=0; i<gameSettings->getFactionCount(); ++i){
|
||||
int slot=gameSettings->getStartLocationIndex(i);
|
||||
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i),errorOnMissingData);
|
||||
listBoxRMultiplier[slot].setSelectedItemIndex((gameSettings->getResourceMultiplier(i)-rMultiplierOffset)*10);
|
||||
listBoxRMultiplier[slot].setSelectedItemIndex((gameSettings->getResourceMultiplierIndex(i)));
|
||||
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i),errorOnMissingData);
|
||||
//listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),errorOnMissingData);
|
||||
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),false);
|
||||
|
|
|
@ -135,7 +135,6 @@ private:
|
|||
|
||||
std::vector<std::string> tileSets;
|
||||
|
||||
float rMultiplierOffset;
|
||||
public:
|
||||
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||
|
|
|
@ -61,7 +61,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
currentFactionName_factionPreview="";
|
||||
mapPreviewTexture=NULL;
|
||||
|
||||
rMultiplierOffset=0.5f;
|
||||
|
||||
publishToMasterserverThread = NULL;
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -411,7 +410,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
controlItems.push_back(lang.get("Human"));
|
||||
|
||||
for(int i=0; i<45; ++i){
|
||||
rMultiplier.push_back(floatToStr(rMultiplierOffset+0.1f*i,1));
|
||||
rMultiplier.push_back(floatToStr(0.5f+0.1f*i,1));
|
||||
}
|
||||
|
||||
if(config.getBool("EnableNetworkCpu","false") == true) {
|
||||
|
@ -910,7 +909,7 @@ void MenuStateCustomGame::updateAllResourceMultiplier() {
|
|||
void MenuStateCustomGame::updateResourceMultiplier(const int index) {
|
||||
ControlType ct= static_cast<ControlType>(listBoxControls[index].getSelectedItemIndex());
|
||||
if(ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(10*(1.0f-rMultiplierOffset));
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(5);
|
||||
listBoxRMultiplier[index].setEnabled(false);
|
||||
}
|
||||
else if(ct == ctCpuEasy || ct == ctNetworkCpuEasy)
|
||||
|
@ -919,17 +918,17 @@ void MenuStateCustomGame::updateResourceMultiplier(const int index) {
|
|||
listBoxRMultiplier[index].setEnabled(true);
|
||||
}
|
||||
else if(ct == ctCpu || ct == ctNetworkCpu) {
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(10*(1.0f-rMultiplierOffset));
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(5);
|
||||
listBoxRMultiplier[index].setEnabled(true);
|
||||
}
|
||||
else if(ct == ctCpuUltra || ct == ctNetworkCpuUltra)
|
||||
{
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(10*(1.0f-rMultiplierOffset)+10);
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(25);
|
||||
listBoxRMultiplier[index].setEnabled(true);
|
||||
}
|
||||
else if(ct == ctCpuMega || ct == ctNetworkCpuMega)
|
||||
{
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(10*(1.0f-rMultiplierOffset)+30);
|
||||
listBoxRMultiplier[index].setSelectedItemIndex(35);
|
||||
listBoxRMultiplier[index].setEnabled(true);
|
||||
}
|
||||
listBoxRMultiplier[index].setEditable(listBoxRMultiplier[index].getEnabled());
|
||||
|
@ -1975,7 +1974,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
//labelPlayerNames[i].setText(getHumanPlayerName(i));
|
||||
//SetActivePlayerNameEditor();
|
||||
}
|
||||
gameSettings->setResourceMultiplier(slotIndex, rMultiplierOffset+listBoxRMultiplier[i].getSelectedItemIndex()*0.1f);
|
||||
gameSettings->setResourceMultiplierIndex(slotIndex, listBoxRMultiplier[i].getSelectedItemIndex());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||
|
@ -2042,7 +2041,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
gameSettings->setFactionControl(slotIndex, ct);
|
||||
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
||||
gameSettings->setStartLocationIndex(slotIndex, i);
|
||||
gameSettings->setResourceMultiplier(slotIndex, 1.0f);
|
||||
gameSettings->setResourceMultiplierIndex(slotIndex, 10);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
|
@ -2115,7 +2114,7 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||
int slotIndex = gameSettings.getStartLocationIndex(i);
|
||||
|
||||
saveGameFile << "FactionControlForIndex" << slotIndex << "=" << gameSettings.getFactionControl(i) << std::endl;
|
||||
saveGameFile << "ResourceMultiplier" << slotIndex << "=" << gameSettings.getResourceMultiplier(i) << std::endl;
|
||||
saveGameFile << "ResourceMultiplierIndex" << slotIndex << "=" << gameSettings.getResourceMultiplierIndex(i) << std::endl;
|
||||
saveGameFile << "FactionTeamForIndex" << slotIndex << "=" << gameSettings.getTeam(i) << std::endl;
|
||||
saveGameFile << "FactionStartLocationForIndex" << slotIndex << "=" << gameSettings.getStartLocationIndex(i) << std::endl;
|
||||
saveGameFile << "FactionTypeNameForIndex" << slotIndex << "=" << gameSettings.getFactionTypeName(i) << std::endl;
|
||||
|
@ -2171,7 +2170,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
//for(int i = 0; i < gameSettings.getFactionCount(); ++i) {
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
gameSettings.setFactionControl(i,(ControlType)properties.getInt(string("FactionControlForIndex") + intToStr(i),intToStr(ctClosed).c_str()) );
|
||||
gameSettings.setResourceMultiplier(i,properties.getFloat(string("ResourceMultiplier") + intToStr(i),"1.0"));
|
||||
gameSettings.setResourceMultiplierIndex(i,properties.getInt(string("ResourceMultiplierIndex") + intToStr(i),"5"));
|
||||
gameSettings.setTeam(i,properties.getInt(string("FactionTeamForIndex") + intToStr(i),"0") );
|
||||
gameSettings.setStartLocationIndex(i,properties.getInt(string("FactionStartLocationForIndex") + intToStr(i),intToStr(i).c_str()) );
|
||||
gameSettings.setFactionTypeName(i,properties.getString(string("FactionTypeNameForIndex") + intToStr(i),"?") );
|
||||
|
@ -2241,7 +2240,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
listBoxControls[i].setSelectedItemIndex(gameSettings.getFactionControl(i));
|
||||
updateResourceMultiplier(i);
|
||||
listBoxRMultiplier[i].setSelectedItemIndex((gameSettings.getResourceMultiplier(i)-rMultiplierOffset)*10);
|
||||
listBoxRMultiplier[i].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
|
||||
listBoxTeams[i].setSelectedItemIndex(gameSettings.getTeam(i));
|
||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo
|
|||
}
|
||||
else if(factionControl==ctCpuMega)
|
||||
{
|
||||
scenarioInfo->resourceMultipliers[i]=4.0f;
|
||||
scenarioInfo->resourceMultipliers[i]=3.5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ void MenuStateScenario::loadGameSettings(const ScenarioInfo *scenarioInfo, GameS
|
|||
gameSettings->setThisFactionIndex(factionCount);
|
||||
}
|
||||
gameSettings->setFactionControl(factionCount, ct);
|
||||
gameSettings->setResourceMultiplier(factionCount, scenarioInfo->resourceMultipliers[i]);
|
||||
gameSettings->setResourceMultiplierIndex(factionCount, (scenarioInfo->resourceMultipliers[i]-0.5f)/0.1f);
|
||||
gameSettings->setTeam(factionCount, scenarioInfo->teams[i]-1);
|
||||
gameSettings->setStartLocationIndex(factionCount, i);
|
||||
gameSettings->setFactionTypeName(factionCount, scenarioInfo->factionTypeNames[i]);
|
||||
|
|
|
@ -237,7 +237,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i);
|
||||
data.factionControls[i]= gameSettings->getFactionControl(i);
|
||||
data.resourceMultiplier[i]= 10*(gameSettings->getResourceMultiplier(i));
|
||||
data.resourceMultiplierIndex[i]= gameSettings->getResourceMultiplierIndex(i);
|
||||
data.teams[i]= gameSettings->getTeam(i);
|
||||
data.startLocationIndex[i]= gameSettings->getStartLocationIndex(i);
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
|
|||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
||||
gameSettings->setFactionControl(i, static_cast<ControlType>(data.factionControls[i]));
|
||||
gameSettings->setResourceMultiplier(i,data.resourceMultiplier[i]*0.1f);
|
||||
gameSettings->setResourceMultiplierIndex(i,data.resourceMultiplierIndex[i]);
|
||||
gameSettings->setTeam(i, data.teams[i]);
|
||||
gameSettings->setStartLocationIndex(i, data.startLocationIndex[i]);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ private:
|
|||
NetworkString<maxSmallStringSize> networkPlayerNames[GameConstants::maxPlayers]; //networkPlayerNames
|
||||
|
||||
int8 factionControls[GameConstants::maxPlayers];
|
||||
int8 resourceMultiplier[GameConstants::maxPlayers];
|
||||
int8 resourceMultiplierIndex[GameConstants::maxPlayers];
|
||||
|
||||
int8 thisFactionIndex;
|
||||
int8 factionCount;
|
||||
|
|
|
@ -768,7 +768,19 @@ void UnitUpdater::updateHarvest(Unit *unit) {
|
|||
// }
|
||||
if(unit->getFaction()->getCpuControl())
|
||||
{
|
||||
resourceAmount*=game->getGameSettings()->getResourceMultiplier(unit->getFaction()->getIndex());
|
||||
/* Get the current time. */
|
||||
// time_t curtime = time (NULL);
|
||||
// /* Convert it to local time representation. */
|
||||
// struct tm *loctime = localtime (&curtime);
|
||||
// char szBuf2[100]="";
|
||||
// strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime);
|
||||
// printf("%s: org. resourceamount :%d ",szBuf2,resourceAmount);
|
||||
|
||||
printf("org. resourceamount :%d ",resourceAmount);
|
||||
int resourceMultiplierIndex=game->getGameSettings()->getResourceMultiplierIndex(unit->getFaction()->getIndex());
|
||||
resourceAmount=(resourceAmount* (resourceMultiplierIndex +5))/10;
|
||||
printf("calc. resourceamount :%d ",resourceAmount);
|
||||
printf("index+5 :%d \n",resourceMultiplierIndex+5);
|
||||
}
|
||||
unit->getFaction()->incResourceAmount(unit->getLoadType(), resourceAmount);
|
||||
world->getStats()->harvest(unit->getFactionIndex(), resourceAmount);
|
||||
|
|
|
@ -961,7 +961,7 @@ void World::initFactionTypes(GameSettings *gs) {
|
|||
stats.setFactionTypeName(i, formatString(gs->getFactionTypeName(i)));
|
||||
stats.setPersonalityType(i, getFaction(i)->getType()->getPersonalityType());
|
||||
stats.setControl(i, gs->getFactionControl(i));
|
||||
stats.setResourceMultiplier(i,gs->getResourceMultiplier(i));
|
||||
stats.setResourceMultiplier(i,(gs->getResourceMultiplierIndex(i)+5)*0.1f);
|
||||
stats.setPlayerName(i,gs->getNetworkPlayerName(i));
|
||||
stats.setPlayerColor(i,getFaction(i)->getTexture()->getPixmapConst()->getPixel3f(0, 0));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue