Added map tests and map type properties to all maps.
This commit is contained in:
parent
bf84196cb0
commit
008f6a28f6
@ -54,6 +54,7 @@ SUCH DAMAGE.
|
||||
#include "Toggleable.h"
|
||||
#include "Unlock.h"
|
||||
#include "State_OverworldMap.h"
|
||||
#include "Test.h"
|
||||
|
||||
INCLUDE_EMITTER_LIST
|
||||
|
||||
@ -1722,6 +1723,8 @@ void Crawler::InitializeLevels(){
|
||||
INITLEVEL(BOSS_1);
|
||||
INITLEVEL(CAMPAIGN_1_2);
|
||||
|
||||
Test::RunMapTests();
|
||||
|
||||
LEVEL_NAMES.SetInitialized();
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,18 @@
|
||||
"object"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "#ff00ff33",
|
||||
"drawFill": true,
|
||||
"id": 23,
|
||||
"members": [
|
||||
],
|
||||
"name": "EndZone",
|
||||
"type": "class",
|
||||
"useAs": [
|
||||
"object"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "#ffd9d929",
|
||||
"drawFill": true,
|
||||
@ -98,7 +110,22 @@
|
||||
"valuesAsFlags": false
|
||||
},
|
||||
{
|
||||
"color": "#ffc3ae44",
|
||||
"id": 25,
|
||||
"name": "LevelType",
|
||||
"storageType": "string",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
"Dungeon",
|
||||
"Boss",
|
||||
"Story",
|
||||
"Blacksmith",
|
||||
"Unspecified",
|
||||
"World Map"
|
||||
],
|
||||
"valuesAsFlags": false
|
||||
},
|
||||
{
|
||||
"color": "#fffff700",
|
||||
"drawFill": true,
|
||||
"id": 9,
|
||||
"members": [
|
||||
@ -128,6 +155,12 @@
|
||||
"drawFill": true,
|
||||
"id": 19,
|
||||
"members": [
|
||||
{
|
||||
"name": "Level Type",
|
||||
"propertyType": "LevelType",
|
||||
"type": "string",
|
||||
"value": "Unspecified"
|
||||
},
|
||||
{
|
||||
"name": "Optimize",
|
||||
"type": "bool",
|
||||
|
@ -311,6 +311,7 @@
|
||||
<ClInclude Include="State_GameRun.h" />
|
||||
<ClInclude Include="State_MainMenu.h" />
|
||||
<ClInclude Include="State_OverworldMap.h" />
|
||||
<ClInclude Include="Test.h" />
|
||||
<ClInclude Include="Theme.h" />
|
||||
<ClInclude Include="TMXParser.h" />
|
||||
<ClInclude Include="Toggleable.h" />
|
||||
@ -365,6 +366,7 @@
|
||||
<ClCompile Include="State_GameRun.cpp" />
|
||||
<ClCompile Include="State_MainMenu.cpp" />
|
||||
<ClCompile Include="State_OverworldMap.cpp" />
|
||||
<ClCompile Include="Test.cpp" />
|
||||
<ClCompile Include="TestMenu.cpp" />
|
||||
<ClCompile Include="TestSubMenu.cpp" />
|
||||
<ClCompile Include="Thief.cpp" />
|
||||
|
@ -249,6 +249,9 @@
|
||||
<ClInclude Include="MenuItemItemButton.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Test.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
@ -416,6 +419,9 @@
|
||||
<ClCompile Include="ItemLoadoutWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Test.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
@ -30,7 +30,8 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <ostream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#ifndef __EMSCRIPTEN__
|
||||
#include <source_location>
|
||||
#endif
|
||||
@ -46,6 +47,7 @@ SUCH DAMAGE.
|
||||
#undef ERR //Stupid Windows
|
||||
|
||||
#ifndef __EMSCRIPTEN__
|
||||
//WARNING! err accepts a stream of data using << operators. If you want to concatenate strings via the + operator, you must wrap the entire operation in ()
|
||||
#define ERR(err) { \
|
||||
std::stringstream errStream; \
|
||||
errStream<<err; \
|
||||
|
@ -81,6 +81,7 @@ struct Map{
|
||||
Renderable*optimizedTile=nullptr;
|
||||
std::vector<XMLTag> TilesetData;
|
||||
std::vector<LayerTag> LayerData;
|
||||
std::string mapType="";
|
||||
std::set<int>spawns;
|
||||
std::map<int,SpawnerTag> SpawnerData; //Spawn groups have IDs, mobs associate which spawner they are tied to via this ID.
|
||||
std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
||||
@ -319,21 +320,12 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
||||
if (newTag.tag=="property"&&newTag.data["name"]=="Boss Title Display") {
|
||||
parsedMapInfo.SpawnerData[prevSpawner].bossNameDisplay=newTag.data["value"];
|
||||
} else
|
||||
if (newTag.tag=="property"&&newTag.data["name"]=="Level Type") {
|
||||
parsedMapInfo.mapType=newTag.data["value"];
|
||||
} else
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="PlayerSpawnLocation") {
|
||||
parsedMapInfo.MapData.playerSpawnLocation={newTag.GetInteger("x")-newTag.GetInteger("width")/2,newTag.GetInteger("y")-newTag.GetInteger("height")/2};
|
||||
} else
|
||||
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()
|
||||
&&(newTag.data["type"]=="LowerZone"||newTag.data["type"]=="UpperZone")){
|
||||
//This is an object with a type that doesn't fit into other categories, we can add it to ZoneData.
|
||||
if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){
|
||||
std::vector<geom2d::rect<int>>&zones=parsedMapInfo.ZoneData[newTag.data["type"]];
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
} else {
|
||||
std::vector<geom2d::rect<int>>zones;
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
parsedMapInfo.ZoneData[newTag.data["type"]]=zones;
|
||||
}
|
||||
}else
|
||||
if (newTag.tag=="object"&&newTag.data["type"]=="Monster") {
|
||||
//XMLTag monsterTag=ReadNextTag();
|
||||
//XMLTag spawnerLinkTag=ReadNextTag();
|
||||
@ -360,6 +352,17 @@ typedef std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
|
||||
} else
|
||||
if(newTag.tag=="property"&¤tStagePlate!=nullptr){
|
||||
currentStagePlate->properties[newTag.data["name"]]={newTag.data["name"],newTag.data["value"]};
|
||||
}else
|
||||
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){
|
||||
//This is an object with a type that doesn't fit into other categories, we can add it to ZoneData.
|
||||
if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){
|
||||
std::vector<geom2d::rect<int>>&zones=parsedMapInfo.ZoneData[newTag.data["type"]];
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
} else {
|
||||
std::vector<geom2d::rect<int>>zones;
|
||||
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
|
||||
parsedMapInfo.ZoneData[newTag.data["type"]]=zones;
|
||||
}
|
||||
}else{
|
||||
if(_DEBUG_MAP_LOAD_INFO)std::cout<<"Unsupported tag format! Ignoring."<<"\n";
|
||||
}
|
||||
|
61
Crawler/Test.cpp
Normal file
61
Crawler/Test.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2018 - 2023 OneLoneCoder.com
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
#include "Test.h"
|
||||
#include "Error.h"
|
||||
#include "Crawler.h"
|
||||
#include "DEFINES.h"
|
||||
|
||||
INCLUDE_game
|
||||
|
||||
int Test::totalTests=0;
|
||||
|
||||
void Test::is(std::string conditionStr,bool testResult){
|
||||
std::cout<<"Running test "<<Test::totalTests<<std::endl;
|
||||
if(!testResult){
|
||||
ERR(("\t"+conditionStr+" returned FALSE"));
|
||||
}
|
||||
Test::totalTests++;
|
||||
};
|
||||
|
||||
void Test::RunMapTests(){
|
||||
is("There are two LowerBridgeCollision zones in Campaign I-I",
|
||||
game->MAP_DATA.at(CAMPAIGN_1_1).ZoneData.count("LowerBridgeCollision")
|
||||
&&game->MAP_DATA.at(CAMPAIGN_1_1).ZoneData.at("LowerBridgeCollision").size()>=2);
|
||||
for(auto&key:game->MAP_DATA){
|
||||
is("A Map type has been selected for map "+std::to_string(key.first),
|
||||
key.second.mapType!=""&&key.second.mapType!="Unspecified");
|
||||
if(key.second.mapType=="Dungeon"){
|
||||
is("There is an EndZone in Dungeon "+std::to_string(key.first),
|
||||
key.second.ZoneData.count("EndZone"));
|
||||
}
|
||||
}
|
||||
}
|
39
Crawler/Test.h
Normal file
39
Crawler/Test.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2018 - 2023 OneLoneCoder.com
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
#include <string>
|
||||
|
||||
class Test{
|
||||
static int totalTests;
|
||||
static void is(std::string conditionStr,bool testResult);
|
||||
public:
|
||||
static void RunMapTests();
|
||||
};
|
@ -33,7 +33,7 @@ SUCH DAMAGE.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 2860
|
||||
#define VERSION_BUILD 2876
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="9" nextobjectid="138">
|
||||
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="9" nextobjectid="139">
|
||||
<properties>
|
||||
<property name="Level Type" propertytype="LevelType" value="Dungeon"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="../maps/Tilesheet_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="2913" source="../maps/Decorations_c1_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="4533" source="../maps/24x24_Waterfall.tsx"/>
|
||||
@ -1266,6 +1269,7 @@
|
||||
<object id="122" type="LowerBridgeCollision" x="4032" y="2232" width="24" height="144"/>
|
||||
<object id="123" name="Upper Zone" type="UpperZone" x="4056" y="1938" width="816" height="780"/>
|
||||
<object id="124" name="Upper Zone" type="UpperZone" x="4176" y="1848" width="534" height="90"/>
|
||||
<object id="138" name="End Zone" type="EndZone" x="4728" y="2184" width="192" height="168"/>
|
||||
</objectgroup>
|
||||
<objectgroup id="5" name="Spawn Groups">
|
||||
<object id="2" name="Spawn Group 1" type="SpawnGroup" x="870" y="4008" width="558.667" height="576">
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="174" height="144" tilewidth="24" tileheight="24" infinite="0" nextlayerid="6" nextobjectid="7">
|
||||
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="right-down" width="174" height="144" tilewidth="24" tileheight="24" infinite="0" nextlayerid="6" nextobjectid="9">
|
||||
<properties>
|
||||
<property name="Level Type" propertytype="LevelType" value="Dungeon"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="../maps/Tilesheet_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="2913" source="../maps/Decorations_c1_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="4533" source="../maps/24x24_Waterfall.tsx"/>
|
||||
@ -614,5 +617,6 @@
|
||||
</properties>
|
||||
<point/>
|
||||
</object>
|
||||
<object id="7" name="End Zone" type="EndZone" x="1320" y="1368" width="72" height="72"/>
|
||||
</objectgroup>
|
||||
</map>
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" orientation="orthogonal" renderorder="right-down" width="64" height="80" tilewidth="24" tileheight="24" infinite="0" nextlayerid="5" nextobjectid="6">
|
||||
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="right-down" width="64" height="80" tilewidth="24" tileheight="24" infinite="0" nextlayerid="5" nextobjectid="6">
|
||||
<properties>
|
||||
<property name="Level Type" propertytype="LevelType" value="Boss"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="../maps/Tilesheet_No_Shadow24x24.tsx"/>
|
||||
<tileset firstgid="2913" source="../maps/Decorations_c1_No_Shadow24x24.tsx"/>
|
||||
<layer id="1" name="Layer 1" width="64" height="80">
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.1" class="Map" orientation="orthogonal" renderorder="left-down" width="250" height="177" tilewidth="4" tileheight="4" infinite="0" nextlayerid="5" nextobjectid="12">
|
||||
<properties>
|
||||
<property name="Level Type" propertytype="LevelType" value="World Map"/>
|
||||
<property name="Optimize" type="bool" value="true"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="../maps/Minifantasy_TinyOverworldAllTiles.tsx"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user