Selaa lähdekoodia

* new command - "get txt" - VCMI will extract all .txt files from h3bitmap.lod to the Extracted_txts/ folder.
* more detailed logs
* version changed to 0.55

Michał W. Urbańczyk 17 vuotta sitten
vanhempi
sitoutus
1e7f8984e2
4 muutettua tiedostoa jossa 49 lisäystä ja 8 poistoa
  1. 28 0
      CConsoleHandler.cpp
  2. 19 5
      CMT.cpp
  3. 1 2
      hch/CLodHandler.cpp
  4. 1 1
      stdafx.h

+ 28 - 0
CConsoleHandler.cpp

@@ -13,6 +13,9 @@
 #include <sstream>
 #include "SDL_Extensions.h"
 #include "hch/CHeroHandler.h"
+#include "hch/CLodHandler.h"
+#include "boost/filesystem/operations.hpp"
+#include <boost/algorithm/string.hpp>
 int internalFunc(void * callback)
 {
 	CCallback * cb = (CCallback*)callback;
@@ -33,6 +36,31 @@ int internalFunc(void * callback)
 
 		if(pom==std::string("die, fool"))
 			exit(0);
+		else if(pom==std::string("get txt"))
+		{
+			boost::filesystem::create_directory("Extracted_txts");
+			std::cout<<"Command accepted. Opening .lod file...\t";
+			CLodHandler * txth = new CLodHandler;
+			txth->init(std::string("Data\\H3bitmap.lod"));
+			std::cout<<"done.\nScanning .lod file\n";
+			int curp=0;
+			std::string pattern = ".TXT";
+			for(int i=0;i<txth->entries.size(); i++)
+			{
+				std::string pom = txth->entries[i].nameStr;
+				if(boost::algorithm::find_last(pom,pattern))
+				{
+					txth->extractFile(std::string("Extracted_txts\\")+pom,pom);
+				}
+				int p2 = ((float)i/(float)txth->entries.size())*(float)100;
+				if(p2!=curp)
+				{
+					curp = p2;
+					std::cout<<"\r"<<curp<<"%";
+				}
+			}
+			std::cout<<"\rExtracting done :)\n";
+		}
 
 		switch (*cn.c_str())
 		{

+ 19 - 5
CMT.cpp

@@ -62,7 +62,7 @@
 CGameInfo* CGI;
 #endif
 #define CHUNK 16384
-const char * NAME = "VCMI 0.54 \"Tirion\" Techdemo";
+const char * NAME = "VCMI 0.55 \"Tirion\" Techdemo";
 
 SDL_Color playerColorPalette[256]; //palette to make interface colors good
 
@@ -757,32 +757,46 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->scenarioOps = cpg->runLoop();
 		THC tmh.getDif();
 
-		cgi->sspriteh = new CSemiLodHandler();
-		cgi->sspriteh->openLod("H3sprite.lod");
+		timeHandler pomtime;pomtime.getDif();
 		CArtHandler * arth = new CArtHandler;
 		arth->loadArtifacts();
 		cgi->arth = arth;
+		THC std::cout<<"\tArtifact handler: "<<pomtime.getDif()<<std::endl;
+
 		CCreatureHandler * creh = new CCreatureHandler;
 		creh->loadCreatures();
 		cgi->creh = creh;
+		THC std::cout<<"\tCreature handler: "<<pomtime.getDif()<<std::endl;
 
 		CSpellHandler * spellh = new CSpellHandler;
 		spellh->loadSpells();
-		cgi->spellh = spellh;
+		cgi->spellh = spellh;		
+		THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
+
 		CBuildingHandler * buildh = new CBuildingHandler;
 		buildh->loadBuildings();
 		cgi->buildh = buildh;
+		THC std::cout<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
+
 		CObjectHandler * objh = new CObjectHandler;
 		objh->loadObjects();
 		cgi->objh = objh;
+		THC std::cout<<"\tObject handler: "<<pomtime.getDif()<<std::endl;
+
 		cgi->dobjinfo = new CDefObjInfoHandler;
 		cgi->dobjinfo->load();
+		THC std::cout<<"\tDef information handler: "<<pomtime.getDif()<<std::endl;
+
 		cgi->state = new CGameState();
 		cgi->state->players = std::map<int, PlayerState>();
+		THC std::cout<<"\tGamestate: "<<pomtime.getDif()<<std::endl;
+
 		cgi->pathf = new CPathfinder();
+		THC std::cout<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
 		cgi->consoleh->cb = new CCallback(cgi->state,-1);
 		cgi->consoleh->runConsole();
-		THC std::cout<<"Handlers initailization: "<<tmh.getDif()<<std::endl;
+		THC std::cout<<"\tCallback and console: "<<pomtime.getDif()<<std::endl;
+		THC std::cout<<"Handlers initailization (together): "<<tmh.getDif()<<std::endl;
 
 		std::string mapname;
 		//if(CPG->ourScenSel->mapsel.selected==0) 

+ 1 - 2
hch/CLodHandler.cpp

@@ -687,7 +687,7 @@ void CLodHandler::extractFile(std::string FName, std::string name)
 		if(buf1!=name)
 			continue;
 		fseek(FLOD, entries[i].offset, 0);
-		std::string bufff = (FName.substr(0, FName.size()-4) + "\\" + (char*)entries[i].name);
+		std::string bufff = (FName);
 		unsigned char * outp;
 		if (entries[i].size==0) //file is not compressed
 		{
@@ -725,7 +725,6 @@ void CLodHandler::extractFile(std::string FName, std::string name)
 		}
 		delete[] outp;
 	}
-	fclose(FLOD);
 }
 
 int CLodHandler::readNormalNr (unsigned char* bufor, int bytCon, bool cyclic)

+ 1 - 1
stdafx.h

@@ -6,7 +6,7 @@
 #pragma once
 
 #define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
-#include <stdio.h>
+#include <cstdio>
 #include <tchar.h>
 #include <string>
 #include <vector>