diff --git a/map.cpp b/map.cpp index 4894858..15724e6 100755 --- a/map.cpp +++ b/map.cpp @@ -477,6 +477,8 @@ namespace battleship{ } void Map::preprareScene(bool empty){ + Game::getSingleton()->setCivilianPlayer(new Player(0, 0, 0, .5 * Vector3::VEC_IJK)); + Root *root = Root::getSingleton(); Node *rootNode = root->getRootNode(); string libPath = root->getLibPath(); @@ -579,9 +581,11 @@ namespace battleship{ loadTerrainObject(i); } - void Map::create(string mapName){ + void Map::create(string mapName, Vector3 mapSize){ this->mapName = mapName; - addSpawnPoint(Vector3::VEC_ZERO); + this->mapSize = mapSize; + + //addSpawnPoint(Vector3::VEC_ZERO); preprareScene(true); } diff --git a/map.h b/map.h index 0268e62..2a99a43 100755 --- a/map.h +++ b/map.h @@ -73,7 +73,7 @@ namespace battleship{ static std::vector generateAdjacentNodeEdges(int, int, int, int, int); void update(); void load(std::string); - void create(std::string); + void create(std::string, vb01::Vector3); void unload(); std::vector raycastTerrain(vb01::Vector3, vb01::Vector3, bool); int getCellId(vb01::Vector3, bool = true); diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 9228217..502bf8f 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -59,8 +59,7 @@ namespace battleship{ if(newMap){ game->addPlayer(new Player(0, 0, 0, Vector3(1, 1, 1))); - map->setMapSize(Vector3(size.x, 0, size.y)); - map->create(name); + map->create(name, Vector3(size.x, 0, size.y)); generatePlane(size); } else{ @@ -583,7 +582,7 @@ namespace battleship{ string assetsPath = GameManager::getSingleton()->getPath(); string mapFolder = assetsPath + "Models/Maps/" + map->getMapName() + "/"; create_directory(mapFolder); - copy_file(assetsPath + DEFAULT_TEXTURE, mapFolder + map->getMapName() + ".jpg"); + copy_file(assetsPath + DEFAULT_TEXTURE, mapFolder + map->getMapName() + ".jpg", filesystem::copy_options::overwrite_existing); vector cells = generateMapCells(); generateLandmassXml(); diff --git a/playButton.cpp b/playButton.cpp index 16feb73..785f5ef 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -66,8 +66,6 @@ namespace battleship{ string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player"); game->addPlayer(new Player(difficulty, faction, team, color, cpuPlayer, i, name)); } - - game->setCivilianPlayer(new Player(0, 0, 0, .5 * Vector3::VEC_IJK)); handleLoadingGui(new LoadingAppState(new InGameAppState(mapName), "inGame.lua")); } diff --git a/unit.cpp b/unit.cpp index 8c17a1d..fe1db3a 100755 --- a/unit.cpp +++ b/unit.cpp @@ -513,15 +513,18 @@ namespace battleship{ //TODO select only the closest cells based on unit size void Unit::placeAt(Vector3 p){ - //check twice in case the unit is warped over a long distance - Map::getSingleton()->blockCells(this); - GameObject::placeAt(p); - Map::getSingleton()->blockCells(this); - ActiveGameState *activeState = (ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE); - if(activeState && activeState->getPlayer()) - Map::Minimap::getSingleton()->updateImage(); + //check twice in case the unit is warped over a long distance + if(activeState) Map::getSingleton()->blockCells(this); + GameObject::placeAt(p); + + if(activeState){ + Map::getSingleton()->blockCells(this); + + if(activeState->getPlayer()) + Map::Minimap::getSingleton()->updateImage(); + } } vector Unit::getSelectingPlayers(){