about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2011-03-12 18:07:57 +0100
committeroy <Tom_Adams@web.de>2011-03-12 18:07:57 +0100
commitb834426548107af96c2568af22cbf8604f230965 (patch)
tree893a04ec6b37d7b1d92ee66d39707463f48e847c /src/engine
parent7b98b3ddeddd34bf0fa0c84b13d928a9dafe140c (diff)
downloadzcatch-b834426548107af96c2568af22cbf8604f230965.tar.gz
zcatch-b834426548107af96c2568af22cbf8604f230965.zip
fixed several problems with spectator view in game and demo player. Closes #83
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/demo.h8
-rw-r--r--src/engine/shared/demo.cpp13
-rw-r--r--src/engine/shared/demo.h2
3 files changed, 23 insertions, 0 deletions
diff --git a/src/engine/demo.h b/src/engine/demo.h
index dacd96dd..3ca68299 100644
--- a/src/engine/demo.h
+++ b/src/engine/demo.h
@@ -20,6 +20,13 @@ public:
 		int m_LastTick;
 	};
 
+	enum
+	{
+		DEMOTYPE_INVALID=0,
+		DEMOTYPE_CLIENT,
+		DEMOTYPE_SERVER,
+	};
+
 	~IDemoPlayer() {}
 	virtual void SetSpeed(float Speed) = 0;
 	virtual int SetPos(float Precent) = 0;
@@ -28,6 +35,7 @@ public:
 	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 int GetDemoType() const = 0;
 };
 
 class IDemoRecorder : public IInterface
diff --git a/src/engine/shared/demo.cpp b/src/engine/shared/demo.cpp
index bf883456..586e7318 100644
--- a/src/engine/shared/demo.cpp
+++ b/src/engine/shared/demo.cpp
@@ -562,6 +562,12 @@ int CDemoPlayer::Load(class IStorage *pStorage, class IConsole *pConsole, const
 		return -1;
 	}
 	
+	// get demo type
+	if(!str_comp(m_Info.m_Header.m_aType, "client"))
+			m_DemoType = DEMOTYPE_CLIENT;
+	else if(!str_comp(m_Info.m_Header.m_aType, "server"))
+		m_DemoType = DEMOTYPE_SERVER;
+	else DEMOTYPE_INVALID;
 	
 	// get map
 	if(m_Info.m_Header.m_Version >= gs_VersionWithMap)
@@ -771,3 +777,10 @@ bool CDemoPlayer::GetDemoInfo(class IStorage *pStorage, const char *pFilename, i
 	io_close(File);
 	return true;
 }
+
+int CDemoPlayer::GetDemoType() const
+{
+	if(m_File)
+		return m_DemoType;
+	return DEMOTYPE_INVALID;
+}
diff --git a/src/engine/shared/demo.h b/src/engine/shared/demo.h
index d8ce70b2..62e2bfd1 100644
--- a/src/engine/shared/demo.h
+++ b/src/engine/shared/demo.h
@@ -94,6 +94,7 @@ private:
 	CKeyFrame *m_pKeyFrames;
 
 	CPlaybackInfo m_Info;
+	int m_DemoType;
 	unsigned char m_aLastSnapshotData[CSnapshot::MAX_SIZE];
 	int m_LastSnapshotDataSize;
 	class CSnapshotDelta *m_pSnapshotDelta;
@@ -119,6 +120,7 @@ public:
 	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;
+	int GetDemoType() const;
 	
 	int Update();