mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
* [new] timeHandler - drobna tymczasowa klasa do pomiarów czasu
* [new] Wypisuje do konsolki czas trwania poszczególnych czynności * [new] Wykorzystuje twoje odkrycie z długością nazwy defa * [deleted] Nie tworzy łze-plików .def * [improvement] Na średniej zwykłej heroesowej mapie działa szybciej ok. 1800 razy
This commit is contained in:
parent
1b552e5029
commit
9da4a74991
@ -34,6 +34,7 @@ void CAmbarCendamo::teceDef()
|
||||
}
|
||||
void CAmbarCendamo::deh3m()
|
||||
{
|
||||
THC timeHandler th;
|
||||
map.version = (Eformat)bufor[0]; //wersja mapy
|
||||
map.areAnyPLayers = bufor[4];
|
||||
map.height = map.width = bufor[5]; // wymiary mapy
|
||||
@ -249,6 +250,7 @@ void CAmbarCendamo::deh3m()
|
||||
}
|
||||
}
|
||||
i+=88;
|
||||
THC std::cout<<"Wczytywanie naglowka: "<<th.getDif()<<std::endl;
|
||||
int rumNr = readNormalNr(i,4);i+=4;
|
||||
for (int it=0;it<rumNr;it++)
|
||||
{
|
||||
@ -261,6 +263,7 @@ void CAmbarCendamo::deh3m()
|
||||
ourRumor.text+=bufor[i++];
|
||||
map.rumors.push_back(ourRumor); //add to our list
|
||||
}
|
||||
THC std::cout<<"Wczytywanie plotek: "<<th.getDif()<<std::endl;
|
||||
i+=156;
|
||||
for (int c=0; c<map.width; c++) // reading terrain
|
||||
{
|
||||
@ -291,28 +294,25 @@ void CAmbarCendamo::deh3m()
|
||||
}
|
||||
}
|
||||
}
|
||||
THC std::cout<<"Wczytywanie terenu: "<<th.getDif()<<std::endl;
|
||||
int defAmount = bufor[i]; // liczba defow
|
||||
i+=8;
|
||||
i+=4;
|
||||
for (int idd = 0 ; idd<defAmount; idd++) // reading defs
|
||||
{
|
||||
int nameLength = readNormalNr(i,4);i+=4;
|
||||
DefInfo vinya; // info about new def
|
||||
while (1) // read name
|
||||
for (int cd=0;cd<nameLength;cd++)
|
||||
{
|
||||
if (bufor[i] == '.' && bufor[i+1] == 'd' && bufor[i+2] == 'e' && bufor[i+3] == 'f')
|
||||
{
|
||||
vinya.name += ".def";
|
||||
i+=4;
|
||||
break;
|
||||
}
|
||||
vinya.name += bufor[i++];
|
||||
}
|
||||
for (int v=0; v<46; v++) // read info
|
||||
for (int v=0; v<42; v++) // read info
|
||||
{
|
||||
vinya.bytes[v] = bufor[i++];
|
||||
}
|
||||
map.defy.push_back(vinya); // add this def to the vector
|
||||
teceDef();
|
||||
//teceDef();
|
||||
}
|
||||
THC std::cout<<"Wczytywanie defow: "<<th.getDif()<<std::endl;
|
||||
//todo: read events
|
||||
}
|
||||
int CAmbarCendamo::readNormalNr (int pos, int bytCon)
|
||||
|
9
CMT.cpp
9
CMT.cpp
@ -11,6 +11,7 @@
|
||||
#include "zlib.h"
|
||||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <fcntl.h>
|
||||
# include <io.h>
|
||||
@ -217,16 +218,24 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
// def(zr,ko,i);
|
||||
// fclose(ko);fclose(zr);
|
||||
//}
|
||||
THC timeHandler tmh;
|
||||
CAmbarCendamo * ac = new CAmbarCendamo("3gryf");
|
||||
THC std::cout<<"Wczytywanie pliku: "<<tmh.getDif()<<std::endl;
|
||||
ac->deh3m();
|
||||
THC std::cout<<"Rozpoznawianie pliku lacznie: "<<tmh.getDif()<<std::endl;
|
||||
ac->loadDefs();
|
||||
THC std::cout<<"Wczytywanie defow: "<<tmh.getDif()<<std::endl;
|
||||
mapHandler * mh = new mapHandler();
|
||||
mh->reader = ac;
|
||||
THC std::cout<<"Stworzenie mapHandlera: "<<tmh.getDif()<<std::endl;
|
||||
mh->init();
|
||||
THC std::cout<<"Inicjalizacja mapHandlera: "<<tmh.getDif()<<std::endl;
|
||||
//SDL_Rect * sr = new SDL_Rect(); sr->h=64;sr->w=64;sr->x=0;sr->y=0;
|
||||
SDL_Surface * teren = mh->terrainRect(0,0,32,32);
|
||||
THC std::cout<<"Przygotowanie terenu do wyswietlenia: "<<tmh.getDif()<<std::endl;
|
||||
SDL_BlitSurface(teren,NULL,ekran,NULL);
|
||||
SDL_Flip(ekran);
|
||||
THC std::cout<<"Wyswietlenie terenu: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
//SDL_Surface * ss = ac->defs[0]->ourImages[0].bitmap;
|
||||
//SDL_BlitSurface(ss, NULL, ekran, NULL);
|
||||
|
8
global.h
8
global.h
@ -1,5 +1,13 @@
|
||||
#ifndef GLOBAL_H
|
||||
#define GLOBAL_H
|
||||
#define CHECKTIME 1
|
||||
#if CHECKTIME
|
||||
#include "timeHandler.h"
|
||||
#include <iostream>
|
||||
#define THC
|
||||
#else
|
||||
#define THC //
|
||||
#endif
|
||||
enum EterrainType {dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
|
||||
enum Eriver {clearRiver=1, icyRiver, muddyRiver, lavaRiver};
|
||||
enum Eroad {dirtRoad=1, gravelRoad, cobblestoneRoad};
|
||||
|
11
timeHandler.h
Normal file
11
timeHandler.h
Normal file
@ -0,0 +1,11 @@
|
||||
#include <ctime>
|
||||
class timeHandler
|
||||
{
|
||||
public:
|
||||
clock_t start, last, mem;
|
||||
timeHandler():start(clock()){last=0;mem=0;};
|
||||
long getDif(){long ret=clock()-last;last=clock();return ret;};
|
||||
void update(){last=clock();};
|
||||
void remember(){mem=clock();};
|
||||
long memDif(){return mem-clock();};
|
||||
};
|
Loading…
Reference in New Issue
Block a user