Skip to content

Commit

Permalink
rename “ascent” to “ascending”
Browse files Browse the repository at this point in the history
   in the descriptions of rooms,
      the code for reading/writing these descriptions
      and the behavior of elevator

ascent is noun, ascend is verb, ascending is adjective

and get rid of legacy code dealing with "<extra>" from old room descriptions
  • Loading branch information
dougmencken committed Oct 28, 2024
1 parent 7cced02 commit 43c8777
Show file tree
Hide file tree
Showing 32 changed files with 46 additions and 68 deletions.
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth19.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<behavior>behavior of elevator</behavior>
<top>7</top>
<bottom>0</bottom>
<ascent>false</ascent>
<ascending>false</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth25.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>false</ascent>
<ascending>false</ascending>
<class>freeitem</class>
</item>
<item x="6" y="2" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth26.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
<behavior>behavior of elevator</behavior>
<top>7</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth29.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="5" y="1" z="0">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth33.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="7" y="0" z="0">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth34.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<behavior>behavior of elevator</behavior>
<top>6</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="4" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth39.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>false</ascent>
<ascending>false</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="6" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth55.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>false</ascent>
<ascending>false</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/blacktooth78.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="7" y="7" z="1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/byblos28.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/byblos29.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<behavior>behavior of elevator</behavior>
<top>6</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="9" y="4" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/byblos40.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
<behavior>behavior of elevator</behavior>
<top>8</top>
<bottom>0</bottom>
<ascent>false</ascent>
<ascending>false</ascending>
<class>freeitem</class>
</item>
<item x="3" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus13.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>2</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="8" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus14.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="4" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus19.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="1" y="5" z="2">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus30.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus31.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="3" y="7" z="0">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/egyptus36.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/penitentiary14.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/penitentiary16.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/penitentiary23.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/penitentiary24.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<behavior>behavior of elevator</behavior>
<top>6</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="4" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/penitentiary9.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
</items>
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/safari12.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="2" y="0" z="0">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/safari3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
<behavior>behavior of elevator</behavior>
<top>8</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="1" y="0" z="-1">
Expand Down
2 changes: 1 addition & 1 deletion gamedata/map/safari34.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<behavior>behavior of elevator</behavior>
<top>9</top>
<bottom>0</bottom>
<ascent>true</ascent>
<ascending>true</ascending>
<class>freeitem</class>
</item>
<item x="6" y="7" z="0">
Expand Down
6 changes: 3 additions & 3 deletions source/Room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,15 +380,15 @@ bool Room::saveAsXML( const std::string & file )

tinyxml2::XMLElement* top = roomXml.NewElement( "top" );
tinyxml2::XMLElement* bottom = roomXml.NewElement( "bottom" );
tinyxml2::XMLElement* ascent = roomXml.NewElement( "ascent" );
tinyxml2::XMLElement* ascending = roomXml.NewElement( "ascending" );

top->SetText( behaviorOfElevator.getTop() );
bottom->SetText( behaviorOfElevator.getBottom() );
ascent->SetText( behaviorOfElevator.getAscent() ? "true" : "false" ); // does it go up first or down?
ascending->SetText( behaviorOfElevator.isAscending() ? "true" : "false" ); // goes it up first or down?

item->InsertEndChild( top );
item->InsertEndChild( bottom );
item->InsertEndChild( ascent );
item->InsertEndChild( ascending );
}
}

Expand Down
28 changes: 3 additions & 25 deletions source/RoomMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,37 +566,15 @@ FreeItemPtr RoomMaker::makeFreeItem( tinyxml2::XMLElement* item, Room* room )
if ( behaviorOfItem == "behavior of elevator" )
{
behaviors::Elevator* behaviorOfElevator = dynamic_cast< behaviors::Elevator* >( freeItem->getBehavior().get () );

tinyxml2::XMLElement* extra = item->FirstChildElement( "extra" );
if ( extra != nilPointer )
{
int data[ 3 ];
int foundEntries = 0;

for ( ; extra != nilPointer ; extra = extra->NextSiblingElement( "extra" ) )
{
data[ foundEntries++ ] = std::atoi( extra->FirstChild()->ToText()->Value() );
if ( foundEntries == 3 ) break ;
}

// three entries are needed
if ( foundEntries == 3 )
{
behaviorOfElevator->setTop( data[ 0 ] );
behaviorOfElevator->setBottom( data[ 1 ] );
behaviorOfElevator->setAscent( data[ 2 ] != 0 );
}
}
else
{
tinyxml2::XMLElement* top = item->FirstChildElement( "top" );
tinyxml2::XMLElement* bottom = item->FirstChildElement( "bottom" );
tinyxml2::XMLElement* ascent = item->FirstChildElement( "ascent" );
std::string ascentString = ascent->FirstChild()->ToText()->Value();
tinyxml2::XMLElement* ascending = item->FirstChildElement( "ascending" );
std::string ascendingString = ascending->FirstChild()->ToText()->Value() ;

behaviorOfElevator->setTop( std::atoi( top->FirstChild()->ToText()->Value() ) );
behaviorOfElevator->setBottom( std::atoi( bottom->FirstChild()->ToText()->Value() ) );
behaviorOfElevator->setAscent( ascentString != "false" );
behaviorOfElevator->setAscending( ascendingString != "false" );
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/behaviors/Elevator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Elevator::Elevator( FreeItem & item, const std::string & behavior )
: Behavior( item, behavior )
, top( Room::MaxLayers )
, bottom( 0 )
, ascent( true )
, ascending( true )
, lastActivity( activities::Activity::Waiting )
, speedTimer( new Timer() )
, waitingTimer( new Timer() )
Expand All @@ -30,7 +30,7 @@ bool Elevator::update ()
switch ( getCurrentActivity() )
{
case activities::Activity::Waiting :
setCurrentActivity ( this->ascent ? activities::ActivityOfElevator::GoingUp : activities::ActivityOfElevator::GoingDown );
setCurrentActivity ( this->ascending ? activities::ActivityOfElevator::GoingUp : activities::ActivityOfElevator::GoingDown );
this->lastActivity = getCurrentActivity ();
break;

Expand Down
20 changes: 10 additions & 10 deletions source/behaviors/Elevator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,34 @@ class Elevator : public Behavior

virtual bool update () ;

int getTop () const { return top ; }
int getTop () const { return this->top ; }

int getBottom () const { return bottom ; }
int getBottom () const { return this->bottom ; }

bool getAscent () const { return ascent ; }
bool isAscending () const { return this->ascending ; }

void setTop ( int top ) { this->top = top ; }
void setTop ( int highest ) { this->top = highest ; }

void setBottom ( int bottom ) { this->bottom = bottom ; }
void setBottom ( int lowest ) { this->bottom = lowest ; }

void setAscent ( bool ascent ) { this->ascent = ascent ; }
void setAscending ( bool ascend ) { this->ascending = ascend ; }

private:

/**
* the maximum height at which elevator ascends
* the maximum height to which this elevator ascends
*/
int top ;

/**
* the minimum height at which elevator descends
* the minimum height to which this elevator descends
*/
int bottom ;

/**
* is the first movement of elevator ascending if true or descending if false
* is the first movement of the elevator ascending if true or descending if false
*/
bool ascent ;
bool ascending ;

/**
* used to retain the previous activity
Expand Down

0 comments on commit 43c8777

Please sign in to comment.