SoD files mod like


#61

I found it in: artifact schema; creature schema; heroClass schema;

Also the description of “index” should be something in the lines of: “used for legacy H3 objects only. Do not include it for new objects. Nodes <node_name_list>, should be used instead”.


#62

I need some help. I try to split .def into bmp. (copy paste code from def2bmp command). I get an error like:

Can someone help me out with this? Here the code for the function.

[code]
#include “…/client/CDefHandler.h”
#include “…/client/gui/SDL_Extensions.h”

void splitDefFile(std::string fileName)
{
if (CResourceHandler::get()->existsResource(ResourceID(“SPRITES/” + fileName)))
{
CDefEssential * cde = CDefHandler::giveDefEss(fileName);

	std::string outName = CResourceHandler::get()->getResource(ResourceID("SPRITES/" + fileName)).getResourceName();
	std::string outPath = VCMIDirs::get().localPath() + "/extracted/";


	boost::filesystem::create_directories(outPath + outName);

	for (size_t i=0; i<cde->ourImages.size(); i++)
	{
		std::string filename = outPath + outName + '/' + boost::lexical_cast<std::string>(i) + ".bmp";
		SDL_SaveBMP(cde->ourImages*.bitmap, filename.c_str());
	}
}
else
	logGlobal->errorStream() << "File not found!";

}
[/code]*


#63

In what project have you put this? Judging by incldue paths it is not client. Therefore, you cannot use methods defined in client, like giveDefEss.
The method either has to be defined in the same project or in the library it links to.


#64

Yes you are right I am in VCMI_lib.

DLL_LINKAGE void preinitDLL(CConsoleHandler *Console)
{
	console = Console;
	VLC = new LibClasses;
	try
	{
		VLC->loadFilesystem();
		parseFolders();
	}
	HANDLE_EXCEPTION;
}

Can/should I move the whole parseFolders() in client? (I just need a quick and dirty solution that works ATM, nothing fancy).


#65

I’m not sure what exactly are you doing, but doing it in client seems reasonable. In client you can use both methods from lib and from client. :slight_smile:

BTW, having the def handling and generally all media handlers in client is not good. Code can not be reused in other projects (tools, editor). For a long time I wanted to split that functionality from client into a new library project. * If I had more time… :(*


#66

I need a for each for each building? Having some troubles…

I try:

const JsonNode &structuresNode = config8[faction]"town"];
BOOST_FOREACH(auto &nodeName, structuresNode"structures"].Struct())
{
	"cove" :
	{
		"town" :
		{
			"structures" : {
				"animatedWater" :
				{
					"animation" : "cove/town-screen/buildings/xx-animated-water",
					"x" : 0,
					"y" : 211,
					"z" : -100500
				},
				"mageGuild1" :
				{
					"animation" : "cove/town-screen/buildings/00-mages-guild-1",
					"area" : "cove/town-screen/buildings-area/00-mages-guild-1",
					"border" : "cove/town-screen/buildings-border/00-mages-guild-1",
					"id" : 0,
					"x" : 337,
					"y" : 110
				},

#67

I am still stuck with the above ^^.

Here what I have for Castle faction right now. It is only configs!!! The needed files will be moved in place automatically (in the near future I hope). All the information should be there, and should be accurate. Here some points that need addressing (one way or the other).

  • The structure I use right now needs the concept of mod lists, otherwise everything has to be dumped into /Mod/Root/.
  • Mod name is not folder name but a variable in every mod.json file. (modIdentifier). (So that every faction now has a similar folder structure free of the faction component)
  • Town mod (cove-like version) was split into faction mod and town mod.
  • I make use of a /Data/image folder. Just like Data/Sprites but for images. (Cove dumps them directly in Data).
  • Guild spells are not accurate. I do not know where to take this info from yet.

So this is my proposal. Please take a look and comment.
SoD.zip (41.3 KB)


#68

That should work. What’s exactly a problem? Note that “auto” in foreach will resolve not to JsonNode but to std::pair<std::string, JsonNode>

I advice to use current structure and switch to mod lists when/if this will be implemented in engine

Current directory is mostly identical to H3. Data is actually H3bitmap archive which contains all H3 images as well as miscellaneous files like fonts, texts, campaigns.
This structure is not perfect and may need separate discussion.

In H3 this is property of the spell. Same goes to hero classes chances. Check H3 txt’s (something like sptraits.txt)


#69

Yeah sorry about that… the code was indeed working but when I was debugging I was looking at a wrong variable.


#70

I want this function in a file in client. I get tons of linker errors… Can it be from includes? What should I include for this to work? Do i need to do anything special?

[code]
void splitDefFile(std::string fileName)
{
if (CResourceHandler::get()->existsResource(ResourceID(“SPRITES/” + fileName)))
{
CDefEssential * cde = CDefHandler::giveDefEss(fileName);

	std::string outName = CResourceHandler::get()->getResource(ResourceID("SPRITES/" + fileName)).getResourceName();
	std::string outPath = VCMIDirs::get().localPath() + "/extracted/";


	boost::filesystem::create_directories(outPath + outName);

	for (size_t i=0; i<cde->ourImages.size(); i++)
	{
		std::string filename = outPath + outName + '/' + boost::lexical_cast<std::string>(i) + ".bmp";
		SDL_SaveBMP(cde->ourImages*.bitmap, filename.c_str());
	}
}
else
	logGlobal->errorStream() << "File not found!";

}
[/code]*


#71

I pasted it into CMT.cpp and it compiled and linked without any errors.
So the question is rather… are you doing anything special?

Please paste them.


#72

Clean Solution -> rebuild solution -> wait 15 mins problems solved… :(.


#73

This solves issues way too often.
Well, still glad to know it is working.


#74

Is there any logic behind dwelling order in FlagPort.def?


#75

THis link maybe helpful:

celestialheavens.com/viewpage.php?id=764

At the end of thread there is a post naming files for creatures by creatures names.


#76

I have some problems extracting def files correctly.

What I try to do: In CLodArchiveLoader::initLODArchive all the info about the file should be available after this line

// Add lod entry to local entries map
		entries[entry.name] = entry;

After this I just try to save the raw data from file-stream in concordance with what there is stored in entry.

Ths function fails to save corectly defs.

void CLodArchiveLoader::extractToFolder( std::string outputSubFolder, CFileInputStream & fileStream, ArchiveEntry entry)
{
		unique_ptr<char]> data = unique_ptr<char]>(new char[entry.size]);
		fileStream.seek(entry.offset);
		fileStream.read((ui8*)data.get(), entry.size);

		std::ofstream out(VCMIDirs::get().dataPath() + "\\Data\\Temp\\" + outputSubFolder + "\\" + entry.name, std::ofstream::binary);
		out.exceptions(std::ifstream::failbit | std::ifstream::badbit);
		out.write(data.get(), entry.size);
}

#77

Why you’re doing this in a hard way? :slight_smile:
In general - you should not modify anything in filesystem directory/ If you want to extract everything (or some set of files) then take a look on code of “extract txt” command.


#78

I try not to depend on any resources being loaded already, that is why I try that method. Can anyone find any flaws in it? (I still haven’t figured it out what I am doing wrong)

EDIT: Figured it out. Some stuff was compressed :(. Here the final function.

void CLodArchiveLoader::extractToFolder( std::string outputSubFolder, ArchiveEntry entry)
{

	std::unique_ptr<CInputStream> & inputStream = load(entry.name);

	unique_ptr<char]> data = unique_ptr<char]>(new char[entry.realSize]);
	inputStream->read((ui8*)data.get(), entry.realSize);

	std::ofstream out(VCMIDirs::get().dataPath() + "\\Data\\Temp\\" + outputSubFolder + "\\" + entry.name, std::ofstream::binary);
	out.exceptions(std::ifstream::failbit | std::ifstream::badbit);
	out.write(data.get(), entry.realSize);
}

#79

I was away for some time… but now the mod files for all factions are close to completion. The functions unpacking and distributing files to the right places as-well.

Before I do the final touches can someone review the structure I am using? ( I am not talking about each lines contents, but a general look at the hierarchy and .json internal structure). I would really appreciate if someone can take a look at castle! faction.

What I did different?

  • having every mod in the root dir creates too much clutter so I used a master mod file that lists mods deeper inside mod folder hierarchy.
  • mod names from dir names do not allow easy copy/pasting for one faction to another. So there is need for a entry for each mod.
  • now there are folders for sound/video/images/sprites inside Data folder. (I think sprites were missing).
  • I have split the town mod into 2 mods: faction and town
  • hero specialties are still hardcore. I do not have (want to have) the knowledge to change those. I propose someone already familiar with that part does those changes.
  • I am still missing some info about 1-2 things but that can be added later. (tavern hero chances, spells available in town).
    SoD_as_Mod.zip (414 KB)

#80

No comments… So I will just finish it as I see it fit and if wanted changes could be made later.