Skip to content

Commit

Permalink
Merge branch 'master' into Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnherfst authored Jan 22, 2019
2 parents 2cdab50 + 98fed42 commit 5ebd449
Show file tree
Hide file tree
Showing 31 changed files with 1,353 additions and 176 deletions.
8 changes: 8 additions & 0 deletions HiveWE/Doodads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ Doodad& Doodads::add_doodad(std::string id, int variation, glm::vec3 position) {
doodad.position = position;
doodad.scale = { 1, 1, 1 };
doodad.angle = 0;

bool is_doodad = doodads_slk.row_header_exists(id);
slk::SLK& slk = is_doodad ? doodads_slk : destructibles_slk;
std::string pathing_texture_path = slk.data("pathTex", id);
if (hierarchy.file_exists(pathing_texture_path)) {
doodad.pathing = resource_manager.load<Texture>(pathing_texture_path);
}

doodad.update();

doodads.push_back(doodad);
Expand Down
12 changes: 12 additions & 0 deletions HiveWE/Doodads.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,16 @@ class Doodads {
void remove_doodads(const std::vector<Doodad*> list);

std::shared_ptr<StaticMesh> get_mesh(std::string id, int variation);
};

// Undo/redo structures
class DoodadsAction : public TerrainUndoAction {
public:
QRect area;
std::vector<Corner> old_corners;
std::vector<Corner> new_corners;
Terrain::undo_type undo_type;

void undo() override;
void redo() override;
};
27 changes: 27 additions & 0 deletions HiveWE/GameCameras.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "stdafx.h"

void GameCameras::load(BinaryReader& reader) {
int version = reader.read<uint32_t>();
if (version != 0) {
std::cout << "Unknown war3map.w3c version: " << version << " Attempting to load but may crash\n";
}

cameras.resize(reader.read<uint32_t>());
for (auto& i : cameras) {
i.target_x = reader.read<float>();
i.target_y = reader.read<float>();
i.z_offset = reader.read<float>();
i.rotation = reader.read<float>();
i.angle_of_attack = reader.read<float>();
i.distance = reader.read<float>();
i.roll = reader.read<float>();
i.fov = reader.read<float>();
i.far_z = reader.read<float>();
i.near_z = reader.read<float>();
i.name = reader.read_c_string();
}
}

void GameCameras::save() {

}
23 changes: 23 additions & 0 deletions HiveWE/GameCameras.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

struct GameCamera {
float target_x;
float target_y;
float z_offset;
float rotation;
float angle_of_attack;
float distance;
float roll;
float fov;
float far_z;
float near_z; // ?
std::string name;
};

class GameCameras {
public:
std::vector<GameCamera> cameras;

void load(BinaryReader& reader);
void save();
};
3 changes: 2 additions & 1 deletion HiveWE/HiveWE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WindowHandler window_handler;
slk::SLK units_slk;
slk::SLK units_meta_slk;
slk::SLK items_slk;
slk::SLK abilities_slk;
slk::SLK doodads_slk;
slk::SLK doodads_meta_slk;
slk::SLK destructibles_slk;
Expand Down Expand Up @@ -134,7 +135,7 @@ void HiveWE::load() {

QString file_name = QFileDialog::getOpenFileName(this, "Open File",
settings.value("openDirectory", QDir::current().path()).toString(),
"Warcraft III Scenario (*.w3x)");
"Warcraft III Scenario (*.w3m *.w3x)");

if (file_name != "") {
settings.setValue("openDirectory", file_name);
Expand Down
2 changes: 2 additions & 0 deletions HiveWE/HiveWE.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern slk::SLK units_meta_slk;

extern slk::SLK items_slk;

extern slk::SLK abilities_slk;

extern slk::SLK doodads_slk;
extern slk::SLK doodads_meta_slk;
extern slk::SLK destructibles_slk;
Expand Down
6 changes: 6 additions & 0 deletions HiveWE/HiveWE.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<ClCompile Include="BLP.cpp" />
<ClCompile Include="Brush.cpp" />
<ClCompile Include="Camera.cpp" />
<ClCompile Include="GameCameras.cpp" />
<ClCompile Include="CASC.cpp" />
<ClCompile Include="CliffMesh.cpp" />
<ClCompile Include="ColorButton.cpp" />
Expand Down Expand Up @@ -345,11 +346,13 @@
<ClCompile Include="PathingPallete.cpp" />
<ClCompile Include="QRibbon.cpp" />
<ClCompile Include="Quadtree.cpp" />
<ClCompile Include="Regions.cpp" />
<ClCompile Include="ResourceManager.cpp" />
<ClCompile Include="Shader.cpp" />
<ClCompile Include="ShadowMap.cpp" />
<ClCompile Include="SkinnedMesh.cpp" />
<ClCompile Include="SLK.cpp" />
<ClCompile Include="Sounds.cpp" />
<ClCompile Include="StaticMesh.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
Expand Down Expand Up @@ -391,6 +394,7 @@
<ClInclude Include="BLP.h" />
<ClInclude Include="Brush.h" />
<ClInclude Include="Camera.h" />
<ClInclude Include="GameCameras.h" />
<ClInclude Include="CASC.h" />
<ClInclude Include="CliffMesh.h" />
<CustomBuild Include="WindowHandler.h">
Expand Down Expand Up @@ -608,11 +612,13 @@
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -D_UNICODE "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I.\Dependencies\glm-0.9.8.5" "-I.\Dependencies\soil2\include" "-I.\Dependencies\stormlib-9.21\include" "-I.\Dependencies\libjpeg-turbo-1.5.2\include" "-I.\Dependencies\casclib-1.11\include" "-I.\Dependencies\qscintilla-2.10.7\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWidgets" "-fstdafx.h" "-f../../%(Filename)%(Extension)"</Command>
</CustomBuild>
<ClInclude Include="Quadtree.h" />
<ClInclude Include="Regions.h" />
<ClInclude Include="ResourceManager.h" />
<ClInclude Include="Shader.h" />
<ClInclude Include="ShadowMap.h" />
<ClInclude Include="SkinnedMesh.h" />
<ClInclude Include="SLK.h" />
<ClInclude Include="Sounds.h" />
<ClInclude Include="StaticMesh.h" />
<CustomBuild Include="Terrain.h">
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='ReleaseSymbols|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
Expand Down
18 changes: 18 additions & 0 deletions HiveWE/HiveWE.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,15 @@
<ClCompile Include="TerrainUndo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Regions.cpp">
<Filter>Source Files\Base</Filter>
</ClCompile>
<ClCompile Include="GameCameras.cpp">
<Filter>Source Files\Base</Filter>
</ClCompile>
<ClCompile Include="Sounds.cpp">
<Filter>Source Files\Base</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
Expand Down Expand Up @@ -515,6 +524,15 @@
<ClInclude Include="TerrainUndo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Regions.h">
<Filter>Header Files\Base</Filter>
</ClInclude>
<ClInclude Include="GameCameras.h">
<Filter>Header Files\Base</Filter>
</ClInclude>
<ClInclude Include="Sounds.h">
<Filter>Header Files\Base</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="HiveWE.h">
Expand Down
8 changes: 6 additions & 2 deletions HiveWE/INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ namespace ini {
}
}

void INI::set_whole_data(const std::string& section, const std::string& key, const std::string& value) {
ini_data[section][key] = { value };
}

std::vector<std::string> INI::whole_data(const std::string& section, const std::string& key) const {
if (ini_data.count(section) && ini_data.at(section).count(key)) { // ToDo C++20 contains
return ini_data.at(section).at(key);
Expand All @@ -99,7 +103,7 @@ namespace ini {
}
}

bool INI::key_exists(const std::string& section, const std::string& key) {
return ini_data.count(section) && ini_data[section].count(key);
bool INI::key_exists(const std::string& section, const std::string& key) const {
return ini_data.count(section) && ini_data.at(section).count(key);
}
}
6 changes: 5 additions & 1 deletion HiveWE/INI.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ namespace ini {
/// To access key data where the value of the key is comma seperated
std::string data(const std::string& section, const std::string& key, const int argument = 0) const;


/// Retrieves the list of key values
std::vector<std::string> whole_data(const std::string& section, const std::string& key) const;

bool key_exists(const std::string& section, const std::string& key);
/// Sets the data of a whole key
void set_whole_data(const std::string& section, const std::string& key, const std::string& value);

bool key_exists(const std::string& section, const std::string& key) const;
};
}
27 changes: 27 additions & 0 deletions HiveWE/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void Map::load(const fs::path& path) {
units_slk.merge(ini::INI("Units/OrcUnitFunc.txt"));
units_slk.merge(ini::INI("Units/UndeadUnitFunc.txt"));
units_slk.merge(ini::INI("Units/NightElfUnitFunc.txt"));
units_slk.merge(ini::INI("Units/CampaignUnitFunc.txt"));
units_slk.merge(ini::INI("Units/NeutralUnitFunc.txt"));

units_slk.merge(ini::INI("Units/HumanUnitStrings.txt"));
Expand All @@ -29,6 +30,15 @@ void Map::load(const fs::path& path) {
units_slk.merge(ini::INI("Units/NightElfUnitStrings.txt"));
units_slk.merge(ini::INI("Units/NeutralUnitStrings.txt"));

abilities_slk = slk::SLK("Units/AbilityData.slk");
abilities_slk.merge(ini::INI("Units/HumanAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/OrcAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/UndeadAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/NightElfAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/CampaignAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/NeutralAbilityFunc.txt"));
abilities_slk.merge(ini::INI("Units/CommonAbilityFunc.txt"));

// Items
items_slk = slk::SLK("Units/ItemData.slk");
items_slk.merge(ini::INI("Units/ItemFunc.txt"));
Expand Down Expand Up @@ -141,10 +151,27 @@ void Map::load(const fs::path& path) {
}
}

if (hierarchy.map.file_exists("war3map.w3r")) {
BinaryReader war3map_w3r(hierarchy.map.file_open("war3map.w3r").read());
regions.load(war3map_w3r);
}

if (hierarchy.map.file_exists("war3map.w3c")) {
BinaryReader war3map_w3c(hierarchy.map.file_open("war3map.w3c").read());
cameras.load(war3map_w3c);
}

if (hierarchy.map.file_exists("war3map.w3s")) {
BinaryReader war3map_w3s(hierarchy.map.file_open("war3map.w3s").read());
sounds.load(war3map_w3s);
}

camera->position = glm::vec3(terrain.width / 2, terrain.height / 2, 10);
camera->reset();

loaded = true;

//triggers.generate_map_script();
}

bool Map::save(const fs::path& path, bool switch_working) {
Expand Down
7 changes: 5 additions & 2 deletions HiveWE/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ class Map {
Terrain terrain;
TerrainUndo terrain_undo;
PathingMap pathing_map;
Imports imports;
Doodads doodads;
Units units;
Imports imports;
Regions regions;
GameCameras cameras;
Sounds sounds;

Brush* brush = nullptr;

Expand All @@ -31,7 +34,7 @@ class Map {

fs::path filesystem_path;

// Temporary for instancing. Replace by some kind of scenenode
// For instancing
std::vector<StaticMesh*> meshes;

double terrain_time;
Expand Down
Loading

0 comments on commit 5ebd449

Please sign in to comment.