diff options
| -rw-r--r-- | data/languages/bosnian.txt | 30 | ||||
| -rw-r--r-- | data/languages/czech.txt | 30 | ||||
| -rw-r--r-- | data/languages/dutch.txt | 30 | ||||
| -rw-r--r-- | data/languages/finnish.txt | 30 | ||||
| -rw-r--r-- | data/languages/french.txt | 30 | ||||
| -rw-r--r-- | data/languages/german.txt | 30 | ||||
| -rw-r--r-- | data/languages/italian.txt | 30 | ||||
| -rw-r--r-- | data/languages/polish.txt | 30 | ||||
| -rw-r--r-- | data/languages/portuguese.txt | 30 | ||||
| -rw-r--r-- | data/languages/romanian.txt | 30 | ||||
| -rw-r--r-- | data/languages/russian.txt | 30 | ||||
| -rw-r--r-- | data/languages/serbian.txt | 30 | ||||
| -rw-r--r-- | data/languages/spanish.txt | 30 | ||||
| -rw-r--r-- | data/languages/swedish.txt | 30 | ||||
| -rw-r--r-- | data/languages/ukrainian.txt | 30 | ||||
| -rw-r--r-- | src/engine/client/client.cpp | 10 | ||||
| -rw-r--r-- | src/engine/demo.h | 15 | ||||
| -rw-r--r-- | src/engine/shared/demo.cpp | 128 | ||||
| -rw-r--r-- | src/engine/shared/demo.h | 16 | ||||
| -rw-r--r-- | src/game/client/components/menus.h | 4 | ||||
| -rw-r--r-- | src/game/client/components/menus_demo.cpp | 77 | ||||
| -rw-r--r-- | src/game/client/components/scoreboard.cpp | 2 |
22 files changed, 616 insertions, 86 deletions
diff --git a/data/languages/bosnian.txt b/data/languages/bosnian.txt index fb75624b..f6bce888 100644 --- a/data/languages/bosnian.txt +++ b/data/languages/bosnian.txt @@ -513,6 +513,9 @@ Your skin ##### needs translation ##### +%d Bytes +== + %s Right click for context menu. == @@ -609,6 +612,12 @@ Color+ Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -648,6 +657,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -735,6 +747,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -747,12 +762,18 @@ Load map Make external == +Map: +== + Name plates size == Name: == +Netversion: +== + New == @@ -891,6 +912,9 @@ Select layer. Right click for properties. Shift == +Size: +== + Sound error == @@ -924,6 +948,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -951,6 +978,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Width == diff --git a/data/languages/czech.txt b/data/languages/czech.txt index c2b4937f..e840bb8c 100644 --- a/data/languages/czech.txt +++ b/data/languages/czech.txt @@ -435,6 +435,9 @@ Your skin ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -561,6 +564,12 @@ Connection Problems... Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -606,6 +615,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -705,6 +717,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -717,6 +732,9 @@ Load map Make external == +Map: +== + Max Screenshots == @@ -729,6 +747,9 @@ Name plates size Name: == +Netversion: +== + New == @@ -882,6 +903,9 @@ Shift Show chat == +Size: +== + Sound error == @@ -921,6 +945,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -948,6 +975,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Warmup == diff --git a/data/languages/dutch.txt b/data/languages/dutch.txt index 5368bca5..6ae16bea 100644 --- a/data/languages/dutch.txt +++ b/data/languages/dutch.txt @@ -960,6 +960,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Adds border tiles == @@ -975,15 +978,33 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == +Demo details +== + Free-View == Game tiles == +Length: +== + +Map: +== + +Netversion: +== + New name: == @@ -996,12 +1017,21 @@ Rename Rename demo == +Size: +== + +Type: +== + Unable to rename the demo == Unhookable == +Version: +== + [ctrl+i] Show tile informations == diff --git a/data/languages/finnish.txt b/data/languages/finnish.txt index 657e54c1..db6cb8fa 100644 --- a/data/languages/finnish.txt +++ b/data/languages/finnish.txt @@ -462,6 +462,9 @@ Your skin ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -582,6 +585,12 @@ Color+ Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -624,6 +633,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -717,6 +729,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -729,6 +744,9 @@ Load map Make external == +Map: +== + Max Screenshots == @@ -741,6 +759,9 @@ Name plates size Name: == +Netversion: +== + New == @@ -888,6 +909,9 @@ Select layer. Right click for properties. Shift == +Size: +== + Sound error == @@ -924,6 +948,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -951,6 +978,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Width == diff --git a/data/languages/french.txt b/data/languages/french.txt index 1e5a00a4..de6d8944 100644 --- a/data/languages/french.txt +++ b/data/languages/french.txt @@ -813,6 +813,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Add Quad == @@ -855,6 +858,12 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new quad layer == @@ -867,6 +876,9 @@ Death Deletes the current quad == +Demo details +== + Enable/disable group for saving == @@ -885,9 +897,18 @@ HD Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + +Map: +== + Name plates size == +Netversion: +== + New name: == @@ -930,6 +951,9 @@ Rotation of the brush in degrees. Use left mouse button to drag and change the v Shift == +Size: +== + Sound error == @@ -957,6 +981,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -975,6 +1002,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + X-axis of the envelope == diff --git a/data/languages/german.txt b/data/languages/german.txt index 7c234037..01b81699 100644 --- a/data/languages/german.txt +++ b/data/languages/german.txt @@ -960,6 +960,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Adds border tiles == @@ -975,15 +978,33 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == +Demo details +== + Free-View == Game tiles == +Length: +== + +Map: +== + +Netversion: +== + New name: == @@ -996,12 +1017,21 @@ Rename Rename demo == +Size: +== + +Type: +== + Unable to rename the demo == Unhookable == +Version: +== + [ctrl+i] Show tile informations == diff --git a/data/languages/italian.txt b/data/languages/italian.txt index 0619f505..a3d46edd 100644 --- a/data/languages/italian.txt +++ b/data/languages/italian.txt @@ -930,6 +930,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Adds border tiles == @@ -945,9 +948,18 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == +Demo details +== + File == @@ -963,12 +975,21 @@ Game tiles HD == +Length: +== + +Map: +== + Max Screenshots == Max demos == +Netversion: +== + New name: == @@ -987,18 +1008,27 @@ Rename demo Shift == +Size: +== + Sound error == Sudden Death == +Type: +== + Unable to rename the demo == Unhookable == +Version: +== + Warmup == diff --git a/data/languages/polish.txt b/data/languages/polish.txt index 033cea1d..60970f29 100644 --- a/data/languages/polish.txt +++ b/data/languages/polish.txt @@ -768,6 +768,9 @@ ZO ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -831,6 +834,12 @@ Color Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == @@ -840,6 +849,9 @@ Delete demo Delete this envelope == +Demo details +== + Down == @@ -876,12 +888,18 @@ Left Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == Load map == +Map: +== + Max Screenshots == @@ -891,6 +909,9 @@ Max demos Name plates size == +Netversion: +== + New folder == @@ -954,6 +975,9 @@ Rotation of the envelope Shift == +Size: +== + Sound error == @@ -969,6 +993,9 @@ Tiles Time limit: %d min == +Type: +== + Unable to delete the demo == @@ -990,6 +1017,9 @@ Use left mouse button to drag and change the color value. Hold shift to be more Use left mouse button to drag and change the value. Hold shift to be more precise. == +Version: +== + X-axis of the envelope == diff --git a/data/languages/portuguese.txt b/data/languages/portuguese.txt index d15a0912..07f8f266 100644 --- a/data/languages/portuguese.txt +++ b/data/languages/portuguese.txt @@ -459,6 +459,9 @@ Your skin ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -579,6 +582,12 @@ Color+ Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -624,6 +633,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -717,6 +729,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -729,6 +744,9 @@ Load map Make external == +Map: +== + Max Screenshots == @@ -741,6 +759,9 @@ Name plates size Name: == +Netversion: +== + New == @@ -888,6 +909,9 @@ Select layer. Right click for properties. Shift == +Size: +== + Sound error == @@ -924,6 +948,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -951,6 +978,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Width == diff --git a/data/languages/romanian.txt b/data/languages/romanian.txt index 66393c90..a8fa0ead 100644 --- a/data/languages/romanian.txt +++ b/data/languages/romanian.txt @@ -960,6 +960,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Adds border tiles == @@ -975,15 +978,33 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == +Demo details +== + Free-View == Game tiles == +Length: +== + +Map: +== + +Netversion: +== + New name: == @@ -996,12 +1017,21 @@ Rename Rename demo == +Size: +== + +Type: +== + Unable to rename the demo == Unhookable == +Version: +== + [ctrl+i] Show tile informations == diff --git a/data/languages/russian.txt b/data/languages/russian.txt index d5239cce..ce33878a 100644 --- a/data/languages/russian.txt +++ b/data/languages/russian.txt @@ -783,6 +783,9 @@ ZO ##### needs translation ##### +%d Bytes +== + %i minute left == @@ -843,6 +846,12 @@ Color Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == @@ -852,6 +861,9 @@ Delete demo Delete this envelope == +Demo details +== + Down == @@ -885,9 +897,15 @@ Left Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load map == +Map: +== + Max Screenshots == @@ -897,6 +915,9 @@ Max demos Name plates size == +Netversion: +== + New folder == @@ -954,6 +975,9 @@ Rotation of the envelope Shift == +Size: +== + Sound error == @@ -969,6 +993,9 @@ Tiles Time limit: %d min == +Type: +== + Unable to delete the demo == @@ -990,6 +1017,9 @@ Use left mouse button to drag and change the color value. Hold shift to be more Use left mouse button to drag and change the value. Hold shift to be more precise. == +Version: +== + X-axis of the envelope == diff --git a/data/languages/serbian.txt b/data/languages/serbian.txt index 694dd4ce..f69e5fc3 100644 --- a/data/languages/serbian.txt +++ b/data/languages/serbian.txt @@ -462,6 +462,9 @@ Your skin ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -582,6 +585,12 @@ Color+ Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -624,6 +633,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -717,6 +729,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -729,6 +744,9 @@ Load map Make external == +Map: +== + Max Screenshots == @@ -741,6 +759,9 @@ Name plates size Name: == +Netversion: +== + New == @@ -888,6 +909,9 @@ Select layer. Right click for properties. Shift == +Size: +== + Sound error == @@ -924,6 +948,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -951,6 +978,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Width == diff --git a/data/languages/spanish.txt b/data/languages/spanish.txt index c7ef0cc6..f63fd345 100644 --- a/data/languages/spanish.txt +++ b/data/languages/spanish.txt @@ -960,6 +960,9 @@ no limit ##### needs translation ##### +%d Bytes +== + Adds border tiles == @@ -975,15 +978,33 @@ Collision Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == +Demo details +== + Free-View == Game tiles == +Length: +== + +Map: +== + +Netversion: +== + New name: == @@ -996,12 +1017,21 @@ Rename Rename demo == +Size: +== + +Type: +== + Unable to rename the demo == Unhookable == +Version: +== + [ctrl+i] Show tile informations == diff --git a/data/languages/swedish.txt b/data/languages/swedish.txt index b1d10fe8..07798a88 100644 --- a/data/languages/swedish.txt +++ b/data/languages/swedish.txt @@ -429,6 +429,9 @@ You must restart the game for all settings to take effect. ##### needs translation ##### +%d Bytes +== + %d%% loaded == @@ -555,6 +558,12 @@ Connection Problems... Constructs game tiles from this layer == +Crc: +== + +Created: +== + Creates a new color envelope == @@ -600,6 +609,9 @@ Deletes the current quad Deletes the layer == +Demo details +== + Detail == @@ -702,6 +714,9 @@ Left mouse button to move. Hold shift to move the texture. Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load == @@ -714,6 +729,9 @@ Load map Make external == +Map: +== + Max Screenshots == @@ -726,6 +744,9 @@ Name plates size Name: == +Netversion: +== + New == @@ -879,6 +900,9 @@ Shift Show chat == +Size: +== + Sound error == @@ -918,6 +942,9 @@ Toggle layer visibility Toggles the envelope editor. == +Type: +== + Unable to delete the demo == @@ -945,6 +972,9 @@ Use left mouse button to drag and create a brush. Use left mouse button to paint with the brush. Right button clears the brush. == +Version: +== + Warmup == diff --git a/data/languages/ukrainian.txt b/data/languages/ukrainian.txt index f080df59..c5b0e776 100644 --- a/data/languages/ukrainian.txt +++ b/data/languages/ukrainian.txt @@ -837,6 +837,9 @@ ZO ##### needs translation ##### +%d Bytes +== + %i minute left == @@ -891,6 +894,12 @@ Color Constructs game tiles from this layer == +Crc: +== + +Created: +== + Death == @@ -900,6 +909,9 @@ Delete demo Delete this envelope == +Demo details +== + File: %s == @@ -915,9 +927,15 @@ Green value of the envelope Left mouse to drag. Hold ctrl to be more precise. Hold shift to alter time point aswell. Right click to delete. == +Length: +== + Load map == +Map: +== + Max Screenshots == @@ -927,6 +945,9 @@ Max demos Name plates size == +Netversion: +== + New name: == @@ -969,12 +990,18 @@ Rotation of the envelope Shift == +Size: +== + Sound error == The audio device couldn't be initialised. == +Type: +== + Unable to delete the demo == @@ -990,6 +1017,9 @@ Up Use Clipping == +Version: +== + X-axis of the envelope == diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 125991c1..5ed0b37b 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -2120,11 +2120,11 @@ const char *CClient::DemoPlayer_Play(const char *pFilename, int StorageType) return "error loading demo"; // load map - Crc = (m_DemoPlayer.Info()->m_Header.m_aCrc[0]<<24)| - (m_DemoPlayer.Info()->m_Header.m_aCrc[1]<<16)| - (m_DemoPlayer.Info()->m_Header.m_aCrc[2]<<8)| - (m_DemoPlayer.Info()->m_Header.m_aCrc[3]); - pError = LoadMapSearch(m_DemoPlayer.Info()->m_Header.m_aMap, Crc); + Crc = (m_DemoPlayer.Info()->m_Header.m_aMapCrc[0]<<24)| + (m_DemoPlayer.Info()->m_Header.m_aMapCrc[1]<<16)| + (m_DemoPlayer.Info()->m_Header.m_aMapCrc[2]<<8)| + (m_DemoPlayer.Info()->m_Header.m_aMapCrc[3]); + pError = LoadMapSearch(m_DemoPlayer.Info()->m_Header.m_aMapName, Crc); if(pError) { DisconnectWithReason(pError); diff --git a/src/engine/demo.h b/src/engine/demo.h index a6841a9e..1ba888a9 100644 --- a/src/engine/demo.h +++ b/src/engine/demo.h @@ -5,6 +5,19 @@ #include "kernel.h" +struct CDemoHeader +{ + unsigned char m_aMarker[7]; + unsigned char m_Version; + char m_aNetversion[64]; + char m_aMapName[64]; + char m_aMapSize[4]; + unsigned char m_aMapCrc[4]; + char m_aType[8]; + char m_aLength[4]; + char m_aTimestamp[20]; +}; + class IDemoPlayer : public IInterface { MACRO_INTERFACE("demoplayer", 0) @@ -34,7 +47,7 @@ public: virtual void Unpause() = 0; virtual const CInfo *BaseInfo() const = 0; virtual char *GetDemoName() = 0; - virtual bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, char *pMap, int BufferSize) const = 0; + virtual bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader) const = 0; virtual int GetDemoType() const = 0; }; diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp index 586e7318..87d0951c 100644 --- a/src/engine/shared/demo.cpp +++ b/src/engine/shared/demo.cpp @@ -2,7 +2,6 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include <base/system.h> #include <engine/console.h> -#include <engine/shared/protocol.h> #include <engine/storage.h> #include "demo.h" #include "memheap.h" @@ -11,12 +10,8 @@ #include "network.h" static const unsigned char gs_aHeaderMarker[7] = {'T', 'W', 'D', 'E', 'M', 'O', 0}; -static const unsigned char gs_ActVersion = 2; -static const unsigned char gs_VersionWithMap = 2; - -//Versions : -//1 : 0.5.0 -//2 : 0.5.3/0.6.0, includes the map +static const unsigned char gs_ActVersion = 3; +static const int gs_LengthOffset = 152; CDemoRecorder::CDemoRecorder(class CSnapshotDelta *pSnapshotDelta) @@ -72,25 +67,21 @@ int CDemoRecorder::Start(class IStorage *pStorage, class IConsole *pConsole, con mem_copy(Header.m_aMarker, gs_aHeaderMarker, sizeof(Header.m_aMarker)); Header.m_Version = gs_ActVersion; str_copy(Header.m_aNetversion, pNetVersion, sizeof(Header.m_aNetversion)); - str_copy(Header.m_aMap, pMap, sizeof(Header.m_aMap)); + str_copy(Header.m_aMapName, pMap, sizeof(Header.m_aMapName)); + int MapSize = io_length(MapFile); + Header.m_aMapSize[0] = (MapSize>>24)&0xff; + Header.m_aMapSize[1] = (MapSize>>16)&0xff; + Header.m_aMapSize[2] = (MapSize>>8)&0xff; + Header.m_aMapSize[3] = (MapSize)&0xff; + Header.m_aMapCrc[0] = (Crc>>24)&0xff; + Header.m_aMapCrc[1] = (Crc>>16)&0xff; + Header.m_aMapCrc[2] = (Crc>>8)&0xff; + Header.m_aMapCrc[3] = (Crc)&0xff; str_copy(Header.m_aType, pType, sizeof(Header.m_aType)); - Header.m_aCrc[0] = (Crc>>24)&0xff; - Header.m_aCrc[1] = (Crc>>16)&0xff; - Header.m_aCrc[2] = (Crc>>8)&0xff; - Header.m_aCrc[3] = (Crc)&0xff; + // Header.m_Length - add this on stop + str_timestamp(Header.m_aTimestamp, sizeof(Header.m_aTimestamp)); io_write(m_File, &Header, sizeof(Header)); - - // write map - // write map size - int MapSize = io_length(MapFile); - unsigned char aBufMapSize[4]; - aBufMapSize[0] = (MapSize>>24)&0xff; - aBufMapSize[1] = (MapSize>>16)&0xff; - aBufMapSize[2] = (MapSize>>8)&0xff; - aBufMapSize[3] = (MapSize)&0xff; - io_write(m_File, &aBufMapSize, sizeof(aBufMapSize)); - // write map data while(1) { @@ -253,6 +244,16 @@ int CDemoRecorder::Stop() { if(!m_File) return -1; + + // add the demo length to the header + io_seek(m_File, gs_LengthOffset, IOSEEK_START); + int DemoLength = Length()/SERVER_TICK_SPEED; + char aLength[4]; + aLength[0] = (DemoLength>>24)&0xff; + aLength[1] = (DemoLength>>16)&0xff; + aLength[2] = (DemoLength>>8)&0xff; + aLength[3] = (DemoLength)&0xff; + io_write(m_File, aLength, sizeof(aLength)); m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_recorder", "Stopped recording"); io_close(m_File); @@ -542,7 +543,6 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const mem_zero(&m_Info, sizeof(m_Info)); m_Info.m_Info.m_FirstTick = -1; m_Info.m_Info.m_LastTick = -1; - //m_Info.start_tick = -1; m_Info.m_NextTick = -1; m_Info.m_Info.m_CurrentTick = -1; m_Info.m_PreviousTick = -1; @@ -561,6 +561,16 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const m_File = 0; return -1; } + + if(m_Info.m_Header.m_Version < gs_ActVersion) + { + char aBuf[256]; + str_format(aBuf, sizeof(aBuf), "demo version %d is not supported", m_Info.m_Header.m_Version); + m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "demo_player", aBuf); + io_close(m_File); + m_File = 0; + return -1; + } // get demo type if(!str_comp(m_Info.m_Header.m_aType, "client")) @@ -569,40 +579,34 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const m_DemoType = DEMOTYPE_SERVER; else DEMOTYPE_INVALID; - // get map - if(m_Info.m_Header.m_Version >= gs_VersionWithMap) - { - // get map size - unsigned char aBufMapSize[4]; - io_read(m_File, &aBufMapSize, sizeof(aBufMapSize)); - int MapSize = (aBufMapSize[0]<<24) | (aBufMapSize[1]<<16) | (aBufMapSize[2]<<8) | (aBufMapSize[3]); - - // check if we already have the map - // TODO: improve map checking (maps folder, check crc) - int Crc = (m_Info.m_Header.m_aCrc[0]<<24) | (m_Info.m_Header.m_aCrc[1]<<16) | (m_Info.m_Header.m_aCrc[2]<<8) | (m_Info.m_Header.m_aCrc[3]); - char aMapFilename[128]; - str_format(aMapFilename, sizeof(aMapFilename), "downloadedmaps/%s_%08x.map", m_Info.m_Header.m_aMap, Crc); - IOHANDLE MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_READ, IStorage::TYPE_ALL); + // read map + int MapSize = (m_Info.m_Header.m_aMapSize[0]<<24) | (m_Info.m_Header.m_aMapSize[1]<<16) | (m_Info.m_Header.m_aMapSize[2]<<8) | (m_Info.m_Header.m_aMapSize[3]); + + // check if we already have the map + // TODO: improve map checking (maps folder, check crc) + int Crc = (m_Info.m_Header.m_aMapCrc[0]<<24) | (m_Info.m_Header.m_aMapCrc[1]<<16) | (m_Info.m_Header.m_aMapCrc[2]<<8) | (m_Info.m_Header.m_aMapCrc[3]); + char aMapFilename[128]; + str_format(aMapFilename, sizeof(aMapFilename), "downloadedmaps/%s_%08x.map", m_Info.m_Header.m_aMapName, Crc); + IOHANDLE MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_READ, IStorage::TYPE_ALL); - if(MapFile) - { - io_skip(m_File, MapSize); - io_close(MapFile); - } - else if(MapSize > 0) - { - // get map data - unsigned char *pMapData = (unsigned char *)mem_alloc(MapSize, 1); - io_read(m_File, pMapData, MapSize); + if(MapFile) + { + io_skip(m_File, MapSize); + io_close(MapFile); + } + else if(MapSize > 0) + { + // get map data + unsigned char *pMapData = (unsigned char *)mem_alloc(MapSize, 1); + io_read(m_File, pMapData, MapSize); - // save map - MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); - io_write(MapFile, pMapData, MapSize); - io_close(MapFile); + // save map + MapFile = pStorage->OpenFile(aMapFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); + io_write(MapFile, pMapData, MapSize); + io_close(MapFile); - // free data - mem_free(pMapData); - } + // free data + mem_free(pMapData); } @@ -758,22 +762,24 @@ char *CDemoPlayer::GetDemoName() return pDemoShortName; } -bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, char *pMap, int BufferSize) const +bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader) const { + if(!pDemoHeader) + return false; + + mem_zero(pDemoHeader, sizeof(CDemoHeader)); + IOHANDLE File = pStorage->OpenFile(pFilename, IOFLAG_READ, StorageType); if(!File) return false; - CDemoHeader Header; - io_read(File, &Header, sizeof(Header)); - if(mem_comp(Header.m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) != 0) + io_read(File, pDemoHeader, sizeof(CDemoHeader)); + if(mem_comp(pDemoHeader->m_aMarker, gs_aHeaderMarker, sizeof(gs_aHeaderMarker)) || pDemoHeader->m_Version < gs_ActVersion) { io_close(File); return false; } - str_copy(pMap, Header.m_aMap, BufferSize); - io_close(File); return true; } diff --git a/src/engine/shared/demo.h b/src/engine/shared/demo.h index ad7566c7..ad8e82b5 100644 --- a/src/engine/shared/demo.h +++ b/src/engine/shared/demo.h @@ -4,17 +4,9 @@ #define ENGINE_SHARED_DEMO_H #include <engine/demo.h> -#include "snapshot.h" +#include <engine/shared/protocol.h> -struct CDemoHeader -{ - unsigned char m_aMarker[7]; - unsigned char m_Version; - char m_aNetversion[64]; - char m_aMap[64]; - unsigned char m_aCrc[4]; - char m_aType[8]; -}; +#include "snapshot.h" class CDemoRecorder : public IDemoRecorder { @@ -39,7 +31,7 @@ public: bool IsRecording() const { return m_File != 0; } - int Length() const { return m_LastTickMarker - m_FirstTick; } + int Length() const { return (m_LastTickMarker - m_FirstTick)/SERVER_TICK_SPEED; } }; class CDemoPlayer : public IDemoPlayer @@ -119,7 +111,7 @@ public: int SetPos(float Precent); const CInfo *BaseInfo() const { return &m_Info.m_Info; } char *GetDemoName(); - bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, char *pMap, int BufferSize) const; + bool GetDemoInfo(class IStorage *pStorage, const char *pFilename, int StorageType, CDemoHeader *pDemoHeader) const; int GetDemoType() const; int Update(); diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 1a2e5cf5..0ad63669 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -6,6 +6,8 @@ #include <base/vmath.h> #include <base/tl/sorted_array.h> +#include <engine/demo.h> + #include <game/client/component.h> #include <game/client/ui.h> @@ -177,7 +179,7 @@ class CMenus : public CComponent bool m_InfosLoaded; bool m_Valid; - char m_aMap[64]; + CDemoHeader m_Info; bool operator<(const CDemoItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index d489b8db..011b1e5e 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -441,7 +441,6 @@ int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType, if(IsDir) { str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName); - Item.m_aMap[0] = 0; Item.m_Valid = false; } else @@ -495,13 +494,13 @@ void CMenus::RenderDemoList(CUIRect MainView) { char aBuffer[512]; str_format(aBuffer, sizeof(aBuffer), "%s/%s", m_aCurrentDemoFolder, Item->m_aFilename); - Item->m_Valid = DemoPlayer()->GetDemoInfo(Storage(), aBuffer, Item->m_StorageType, Item->m_aMap, sizeof(Item->m_aMap)); + Item->m_Valid = DemoPlayer()->GetDemoInfo(Storage(), aBuffer, Item->m_StorageType, &Item->m_Info); Item->m_InfosLoaded = true; } if(!Item->m_Valid) str_copy(aFooterLabel, Localize("Invalid Demo"), sizeof(aFooterLabel)); else - str_format(aFooterLabel, sizeof(aFooterLabel), "%s: %s", Localize("Map"), Item->m_aMap); + str_copy(aFooterLabel, Localize("Demo details"), sizeof(aFooterLabel)); } } @@ -509,7 +508,7 @@ void CMenus::RenderDemoList(CUIRect MainView) RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); MainView.Margin(10.0f, &MainView); - CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, RenameRect, FileIcon; + CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, RenameRect, FileIcon, ListBox; MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar); ButtonBar.HSplitTop(5.0f, 0, &ButtonBar); ButtonBar.VSplitRight(130.0f, &ButtonBar, &PlayRect); @@ -518,10 +517,78 @@ void CMenus::RenderDemoList(CUIRect MainView) ButtonBar.VSplitLeft(120.0f, &DeleteRect, &ButtonBar); ButtonBar.VSplitLeft(10.0f, 0, &ButtonBar); ButtonBar.VSplitLeft(120.0f, &RenameRect, &ButtonBar); + MainView.HSplitBottom(140.0f, &ListBox, &MainView); + + // render demo info + MainView.VMargin(5.0f, &MainView); + MainView.HSplitBottom(5.0f, &MainView, 0); + RenderTools()->DrawUIRect(&MainView, vec4(0,0,0,0.15f), CUI::CORNER_B, 4.0f); + if(!m_DemolistSelectedIsDir && m_DemolistSelectedIndex >= 0 && m_lDemos[m_DemolistSelectedIndex].m_Valid) + { + CUIRect Left, Right, Labels; + MainView.Margin(20.0f, &MainView); + MainView.VSplitMid(&Labels, &MainView); + + // left side + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Created:"), 14.0f, -1); + UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aTimestamp, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Type:"), 14.0f, -1); + UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aType, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Length:"), 14.0f, -1); + int Length = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[1]<<16) | + (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aLength[3]); + char aBuf[64]; + str_format(aBuf, sizeof(aBuf), "%d:%02d", Length/60, Length%60); + UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Version:"), 14.0f, -1); + str_format(aBuf, sizeof(aBuf), "%d", m_lDemos[m_DemolistSelectedIndex].m_Info.m_Version); + UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); + + // right side + Labels = MainView; + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Map:"), 14.0f, -1); + UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapName, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(20.0f, 0, &Left); + Left.VSplitLeft(100.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Size:"), 14.0f, -1); + Length = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[1]<<16) | + (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[3]); + str_format(aBuf, sizeof(aBuf), Localize("%d Bytes"), Length); + UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(20.0f, 0, &Left); + Left.VSplitLeft(100.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Crc:"), 14.0f, -1); + unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) | + (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]); + str_format(aBuf, sizeof(aBuf), "%08x", Crc); + UI()->DoLabelScaled(&Right, aBuf, 14.0f, -1); + Labels.HSplitTop(5.0f, 0, &Labels); + Labels.HSplitTop(20.0f, &Left, &Labels); + Left.VSplitLeft(120.0f, &Left, &Right); + UI()->DoLabelScaled(&Left, Localize("Netversion:"), 14.0f, -1); + UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, -1); + } static int s_DemoListId = 0; static float s_ScrollValue = 0; - UiDoListboxStart(&s_DemoListId, &MainView, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue); + UiDoListboxStart(&s_DemoListId, &ListBox, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue); for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front()) { CListboxItem Item = UiDoListboxNextItem((void*)(&r.front())); diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 95b620c4..c208cddc 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -270,7 +270,7 @@ void CScoreboard::RenderRecordingNotification(float x) //draw the text char aBuf[64]; - int Seconds = m_pClient->DemoRecorder()->Length()/SERVER_TICK_SPEED; + int Seconds = m_pClient->DemoRecorder()->Length(); str_format(aBuf, sizeof(aBuf), Localize("REC %3d:%02d"), Seconds/60, Seconds%60); TextRender()->Text(0, x+50.0f, 10.0f, 20.0f, aBuf, -1); } |