Skip to content

Commit

Permalink
Fixed custom workshops not being properly applied.
Browse files Browse the repository at this point in the history
  • Loading branch information
RosaryMala authored and Timothy Collett committed Sep 23, 2014
1 parent 6937189 commit feee3d4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
6 changes: 2 additions & 4 deletions BuildingConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

bool BuildingNamesTranslatedFromGame = false;

BuildingConfiguration::BuildingConfiguration(string name, int game_type, int game_subtype, std::string str_custom)
BuildingConfiguration::BuildingConfiguration(string name, int game_type, int game_subtype, int32_t custom)
{
this->name = name;
this->game_type = game_type;
this->game_subtype = game_subtype;
this->game_custom = -1;
this->str_custom = str_custom;
this->game_custom = custom;
this->width = this->height = 1;
this->canBeFloating = false;
this->canBeAnySize = false;
Expand All @@ -23,7 +22,6 @@ BuildingConfiguration::BuildingConfiguration()
this->game_type = -1;
this->game_subtype = -1;
this->game_custom = -1;
this->str_custom = str_custom;
this->width = this->height = 1;
this->canBeFloating = false;
this->canBeAnySize = false;
Expand Down
3 changes: 1 addition & 2 deletions BuildingConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ class BuildingConfiguration
int32_t game_type;
int32_t game_subtype;
int32_t game_custom;
std::string str_custom;
uint32_t width, height;
std::string name;
bool canBeFloating;
bool canBeAnySize;
SpriteNode* sprites;

BuildingConfiguration(std::string name, int game_type, int game_subtype, std::string game_custom);
BuildingConfiguration(std::string name, int game_type, int game_subtype, int32_t game_custom);
BuildingConfiguration();
~BuildingConfiguration(void);
};
21 changes: 17 additions & 4 deletions ContentBuildingReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "tinyxml.h"
#include "GUI.h"
#include "ContentLoader.h"
#include "df/world_raws.h"
#include "df/building_def.h"

int parseConditionNode(ConditionalNode* node, TiXmlElement* elemCondition, bool silent);
bool parseSpriteNode(SpriteNode* node, TiXmlElement* elemParent);
Expand Down Expand Up @@ -396,13 +398,24 @@ bool addSingleBuildingConfig( TiXmlElement* elemRoot, vector<BuildingConfigurat
break;
}
}
string custom;
int32_t custom = -1;
// needs custom building spec, doesn't have a string... FAIL
if (needs_custom && !strGameCustom) {
if (needs_custom && (strGameCustom == 0 || strGameCustom[0] == 0)) {
contentError("<building> game_custom attribute is required, but missng.",elemRoot);
return false;
} else if (strGameCustom) {
custom = strGameCustom;
}
else if (strGameCustom && strGameCustom[0])
{
for (int i = 0; i < df::global::world->raws.buildings.all.size(); i++)
{
if (strcmp(strGameCustom, df::global::world->raws.buildings.all[i]->code.c_str()) == 0)
custom = i;
}
if (custom == -1)
{
contentWarning("<building> game_custom attribute is invalid", elemRoot);
return false;
}
}
BuildingConfiguration building(strName, main_type, subtype, custom );
RootTile* spriteroot = new RootTile();
Expand Down
2 changes: 1 addition & 1 deletion Tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void Tile::AssembleTile( void )

bool defaultSnow = 1;
t_SpriteWithOffset sprite;
c_sprite* spriteobject;
c_sprite* spriteobject = 0;

int32_t drawx = 0;
int32_t drawy = 0;
Expand Down
3 changes: 2 additions & 1 deletion resources/buildings/Soapmakers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
<HaveFloor />
<PositionIndex value=0 />
</and>
<sprite index = 202 />
<sprite index = 222 color="building" pattern_index="1" />
<sprite index = 223 />
</else>

<if>
Expand Down
Binary file modified resources/buildings/workshop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit feee3d4

Please sign in to comment.