Skip to content

Commit

Permalink
Allow to pick water type in allwater
Browse files Browse the repository at this point in the history
  • Loading branch information
kelno committed Jul 2, 2021
1 parent e1c720f commit fe743e4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion console_tools/all_water_MCLQ/all_water_MCLQ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ int AllWaterMCLQ::Work(int argc, char* argv[])
//Init
std::string targetADTFilename = argv[2];
float height = (float)atof(argv[3]);
int type = atoi(argv[4]);

std::fstream* targetFile = nullptr;
adt* targetADT = nullptr;
Expand Down Expand Up @@ -37,7 +38,7 @@ int AllWaterMCLQ::Work(int argc, char* argv[])
}

//Set water
targetADT->AllWaterMCLQ(height);
targetADT->AllWaterMCLQ(height, MCNK::MCNKFlags(type));
sLogger->Out(Logger::LogLevel::LOG_LEVEL_NORMAL, "Water set to %f", height);

//Cleaning up
Expand Down
5 changes: 3 additions & 2 deletions console_tools/all_water_MCLQ/all_water_MCLQ.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ class AllWaterMCLQ : public ConsoleTool
//command name
"allwater",
//version
"0.2",
"0.3",
//short description
"Fill adt with (pre-LK) water with given level",
//full description
"Adds 'MCLQ' water that can be parsed by clients of all versions. You should still prefer using the usual AllWater for >= LK clients, which put 'MH20' water, and most tools only supports this one.",
//arguments
{
ToolArgument("target adt", "Set water to this adt"),
ToolArgument("height", "Water height")
ToolArgument("height", "Water height"),
ToolArgument("type", "4 - River / 8 - Ocean / 16 Magma (you can combine them as well)")
}
)
{ }
Expand Down
4 changes: 2 additions & 2 deletions core/adt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ void adt::WriteToDisk(fstream& adtFile)
sLogger->Out(Logger::LOG_LEVEL_NORMAL, "Done writing adt data");
}

void adt::AllWaterMCLQ(float height)
void adt::AllWaterMCLQ(float height,MCNK::MCNKFlags flags)
{
for (int i = 0; i < MCNK::ENTRY_COUNT; i++) {
mcnk->entries[i].mclq = new MCLQ(height, 0.0f, MCLQ_FLAG1_UNK_3, MCLQ_FLAG2_NONE);
mcnk->entries[i].header.flags |= MCNK::FLAG_LQ_RIVER;
mcnk->entries[i].header.flags |= flags;
}
}
2 changes: 1 addition & 1 deletion core/adt.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class adt {
void WriteToDisk(std::fstream& adtFile);

//MCLQ is the only water supported by <= BC clients (this is also retro-supported by later clients)
void AllWaterMCLQ(float height);
void AllWaterMCLQ(float height, MCNK::MCNKFlags flags = MCNK::MCNKFlags::FLAG_LQ_RIVER);
private:
std::vector<char> buffedAdtFile; //adt file
};
Expand Down
2 changes: 1 addition & 1 deletion core/chunks/MCNK.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct MCNKHeader // --schlumpf_ 17:01, 10 August 2009 (CEST), based on: 03-29-2
//a chaque edit qui change la taille changer le mcin
class MCNK {
public:
enum
enum MCNKFlags
{
ENTRY_COUNT = 16*16,

Expand Down

0 comments on commit fe743e4

Please sign in to comment.