- humans may now have a custom resource multiplier

This commit is contained in:
Mark Vejvoda 2012-10-05 22:43:00 +00:00
parent 6b15dfbc51
commit a8b8dcf464
3 changed files with 52 additions and 21 deletions

View File

@ -1100,7 +1100,8 @@ void MenuStateConnectedGame::updateResourceMultiplier(const int index) {
ControlType ct= static_cast<ControlType>(listBoxControls[index].getSelectedItemIndex());
if(ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setEnabled(false);
//listBoxRMultiplier[index].setEnabled(false);
listBoxRMultiplier[index].setEnabled(true);
}
else if(ct == ctCpuEasy || ct == ctNetworkCpuEasy)
{
@ -3758,7 +3759,9 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
}
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i),errorOnMissingData);
listBoxRMultiplier[slot].setSelectedItemIndex((gameSettings->getResourceMultiplierIndex(i),errorOnMissingData));
//printf("Slot %d [%s] resource multiplier index: %d\n",slot,gameSettings->getNetworkPlayerName(i).c_str(),gameSettings->getResourceMultiplierIndex(i));
listBoxRMultiplier[slot].setSelectedItemIndex(gameSettings->getResourceMultiplierIndex(i),errorOnMissingData);
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i),errorOnMissingData);
//listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),errorOnMissingData);
listBoxFactions[slot].setSelectedItem(formatString(gameSettings->getFactionTypeName(i)),false);
@ -3773,10 +3776,12 @@ void MenuStateConnectedGame::setupUIFromGameSettings(GameSettings *gameSettings,
}
ControlType ct= gameSettings->getFactionControl(i);
if (ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
//if (ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
if (ct == ctClosed) {
listBoxRMultiplier[slot].setEnabled(false);
listBoxRMultiplier[slot].setVisible(false);
} else {
}
else {
listBoxRMultiplier[slot].setEnabled(true);
listBoxRMultiplier[slot].setVisible(true);
}

View File

@ -450,7 +450,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
listBoxControls[i].init(xoffset+210, setupPos-30-i*rowHeight);
buttonBlockPlayers[i].registerGraphicComponent(containerName,"buttonBlockPlayers" + intToStr(i));
buttonBlockPlayers[i].init(xoffset+355, setupPos-30-i*rowHeight, 70);
//buttonBlockPlayers[i].init(xoffset+355, setupPos-30-i*rowHeight, 70);
buttonBlockPlayers[i].init(xoffset+250, setupPos-30-i*rowHeight, 70);
buttonBlockPlayers[i].setText(lang.get("BlockPlayer"));
buttonBlockPlayers[i].setFont(CoreData::getInstance().getDisplayFontSmall());
buttonBlockPlayers[i].setFont3D(CoreData::getInstance().getDisplayFontSmall3D());
@ -578,15 +579,17 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
if(this->headlessServerMode == true) {
listBoxControls[0].setSelectedItemIndex(ctNetwork);
updateResourceMultiplier(0);
}
else {
listBoxControls[0].setSelectedItemIndex(ctHuman);
updateResourceMultiplier(0);
}
labelPlayerNames[0].setText("");
labelPlayerNames[0].setText(getHumanPlayerName());
if(openNetworkSlots){
for(int i= 1; i<mapInfo.players; ++i){
if(openNetworkSlots == true) {
for(int i= 1; i< mapInfo.players; ++i){
listBoxControls[i].setSelectedItemIndex(ctNetwork);
}
}
@ -1482,7 +1485,8 @@ void MenuStateCustomGame::updateResourceMultiplier(const int index) {
ControlType ct= static_cast<ControlType>(listBoxControls[index].getSelectedItemIndex());
if(ct == ctHuman || ct == ctNetwork || ct == ctClosed) {
listBoxRMultiplier[index].setSelectedItemIndex((GameConstants::normalMultiplier-0.5f)*10);
listBoxRMultiplier[index].setEnabled(false);
//listBoxRMultiplier[index].setEnabled(false);
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
else if(ct == ctCpuEasy || ct == ctNetworkCpuEasy)
{
@ -1504,7 +1508,8 @@ void MenuStateCustomGame::updateResourceMultiplier(const int index) {
listBoxRMultiplier[index].setEnabled(checkBoxScenario.getValue() == false);
}
listBoxRMultiplier[index].setEditable(listBoxRMultiplier[index].getEnabled());
listBoxRMultiplier[index].setVisible(ct != ctHuman && ct != ctNetwork && ct != ctClosed);
//listBoxRMultiplier[index].setVisible(ct != ctHuman && ct != ctNetwork && ct != ctClosed);
listBoxRMultiplier[index].setVisible(ct != ctClosed);
}
void MenuStateCustomGame::loadGameSettings(std::string fileName) {
@ -1937,15 +1942,6 @@ void MenuStateCustomGame::render() {
listBoxControls[i].getSelectedItemIndex() != ctClosed) {
renderer.renderLabel(&labelPlayerStatus[i]);
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
if( serverInterface != NULL &&
serverInterface->getSlot(i) != NULL &&
serverInterface->getSlot(i)->isConnected()) {
renderer.renderButton(&buttonBlockPlayers[i]);
}
}
}
if(crcPlayerTextureCache[i] != NULL) {
@ -1971,6 +1967,21 @@ void MenuStateCustomGame::render() {
renderer.renderListBox(&listBoxControls[i]);
if( hasNetworkGameSettings() == true &&
listBoxControls[i].getSelectedItemIndex() != ctClosed) {
renderer.renderLabel(&labelPlayerStatus[i]);
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
if( serverInterface != NULL &&
serverInterface->getSlot(i) != NULL &&
serverInterface->getSlot(i)->isConnected()) {
renderer.renderButton(&buttonBlockPlayers[i]);
}
}
}
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
//if(listBoxAdvanced.getSelectedItemIndex() == 1){
renderer.renderListBox(&listBoxRMultiplier[i]);
@ -3160,6 +3171,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
if (listBoxControls[i].getSelectedItemIndex() == ctHuman && this->headlessServerMode == true) {
// switch slot to network, because no human in headless mode
listBoxControls[i].setSelectedItemIndex(ctNetwork) ;
updateResourceMultiplier(i);
}
ControlType ct= static_cast<ControlType>(listBoxControls[i].getSelectedItemIndex());
@ -3195,6 +3207,9 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
else if(serverInterface->getSlot(i) != NULL) {
gameSettings->setNetworkPlayerLanguages(slotIndex, serverInterface->getSlot(i)->getNetworkPlayerLanguage());
}
//if(slotIndex == 0) printf("slotIndex = %d, i = %d, multiplier = %d\n",slotIndex,i,listBoxRMultiplier[i].getSelectedItemIndex());
gameSettings->setResourceMultiplierIndex(slotIndex, listBoxRMultiplier[i].getSelectedItemIndex());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
@ -3638,9 +3653,16 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
listBoxControls[slotIndex].setSelectedItemIndex(gameSettings.getFactionControl(i));
}
//if(slotIndex == 0) printf("#2 slotIndex = %d, i = %d, multiplier = %d\n",slotIndex,i,listBoxRMultiplier[i].getSelectedItemIndex());
updateResourceMultiplier(slotIndex);
//if(slotIndex == 0) printf("#3 slotIndex = %d, i = %d, multiplier = %d\n",slotIndex,i,listBoxRMultiplier[i].getSelectedItemIndex());
listBoxRMultiplier[slotIndex].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
//if(slotIndex == 0) printf("#4 slotIndex = %d, i = %d, multiplier = %d\n",slotIndex,i,listBoxRMultiplier[i].getSelectedItemIndex());
listBoxTeams[slotIndex].setSelectedItemIndex(gameSettings.getTeam(i));
lastSelectedTeamIndex[slotIndex] = listBoxTeams[slotIndex].getSelectedItemIndex();

View File

@ -1163,11 +1163,15 @@ void UnitUpdater::updateHarvest(Unit *unit, int frameIndex) {
if(map->isNextTo(unit, store)) {
//update resources
int resourceMultiplierIndex=game->getGameSettings()->getResourceMultiplierIndex(unit->getFaction()->getIndex());
int resourceAmount= unit->getLoadCount();
if(unit->getFaction()->getCpuControl())
{
int resourceMultiplierIndex=game->getGameSettings()->getResourceMultiplierIndex(unit->getFaction()->getIndex());
//printf("Faction: %d - %s has resource multiplier: %d\n",unit->getFaction()->getStartLocationIndex(),unit->getFaction()->getType()->getName().c_str(),resourceMultiplierIndex);
//if(unit->getFaction()->getCpuControl())
if(resourceMultiplierIndex != 5) {
resourceAmount=(resourceAmount* (resourceMultiplierIndex +5))/10;
//printf("Resource Amount adjusted for Faction: %d - %s has resource multiplier: %d, original vs new amount: %d --> %d\n",unit->getFaction()->getStartLocationIndex(),unit->getFaction()->getType()->getName().c_str(),resourceMultiplierIndex,unit->getLoadCount(),resourceAmount);
}
unit->getFaction()->incResourceAmount(unit->getLoadType(), resourceAmount);
world->getStats()->harvest(unit->getFactionIndex(), resourceAmount);