Permalink
Browse files

dtglib as submodule

  • Loading branch information...
1 parent 6d39a50 commit 17d7ce3e1b7c3ea88ec0651b1a9b237262e49498 @Detegr committed Jul 28, 2012
Showing with 41 additions and 21 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 dtglib
  3. +5 −6 linux/Makefile
  4. +3 −3 src/Game/ClientPlayer.h
  5. +1 −0 src/Main/Server.cpp
  6. +4 −2 src/Main/gfxtest.cpp
  7. +1 −0 src/Network/Client.h
  8. +19 −9 src/Network/Server.cpp
  9. +3 −0 src/Network/Server.h
  10. +1 −1 src/Util/DataUtils.h
View
@@ -0,0 +1,3 @@
+[submodule "dtglib"]
+ path = dtglib
+ url = git@github.com:Detegr/dtglib.git
1 dtglib
Submodule dtglib added at 156a9c
View
@@ -32,23 +32,22 @@ LIBOBJECTS=$(LIBSRC:.cpp=.shared.o)
#********************************************
-INCLUDE=../src
+INCLUDE=-I../src -I../
CLIBS=-L. -lpthread -lpwskoag
-SFML=-lsfml-system -lsfml-window -lsfml-graphics
FPIC=-fPIC
ALL=client server libpwskoag.so
all: $(ALL)
client: $(CLIENTBIN) $(CLIENTOBJECTS) libpwskoag.so
- $(CC) $(CLIENTBIN) -Wl,-rpath,.,-rpath,/usr/local/lib -o $@ $(CLIENTOBJECTS) -I $(INCLUDE) $(CLIBS) $(SFML)
+ $(CC) $(CLIENTBIN) -Wl,-rpath,.,-rpath,/usr/local/lib -o $@ $(CLIENTOBJECTS) $(INCLUDE) $(CLIBS) $(SFML)
server: $(SERVERBIN) $(SERVEROBJECTS) libpwskoag.so
- $(CC) $(SERVERBIN) -Wl,-rpath,. -o $@ $(SERVEROBJECTS) -I $(INCLUDE) $(CLIBS)
+ $(CC) $(SERVERBIN) -Wl,-rpath,. -o $@ $(SERVEROBJECTS) $(INCLUDE) $(CLIBS)
libpwskoag.so: $(LIBOBJECTS)
$(CC) -fPIC -shared -Wl,-soname,$@ -o $@ $(LIBOBJECTS)
%.o : %.cpp
- $(CC) -c -MMD $< -o $@ -I $(INCLUDE) $(CLIBS)
+ $(CC) -c -MMD $< -o $@ $(INCLUDE) $(CLIBS)
%.shared.o : %.cpp
- $(CC) -c -fPIC -MMD $< -o $@ -I $(INCLUDE) $(CLIBS)
+ $(CC) -c -fPIC -MMD $< -o $@ $(INCLUDE) $(CLIBS)
$(LIBOBJECTS) : $(LIBSRC) $(LIBHEADERS)
$(SERVEROBJECTS): $(SERVERSRC) $(SERVERHEADERS)
$(CLIENTOBJECTS): $(CLIENTSRC) $(CLIENTHEADERS)
View
@@ -13,7 +13,7 @@ namespace pwskoag
struct C_GfxEntity : public C_Entity
{
C_GfxEntity() : C_Entity() {}
- C_GfxEntity(TcpSocket* s, C_Packet* p) : C_Entity(s,p) {}
+ C_GfxEntity(C_TcpSocket* s, C_Packet* p) : C_Entity(s,p) {}
virtual const C_Drawable& M_GetDRAW() const=0;
};
@@ -23,11 +23,11 @@ namespace pwskoag
C_PlayerGfx m_Draw;
public:
C_ClientPlayer();
- C_ClientPlayer(TcpSocket *s, C_Packet* p);
+ C_ClientPlayer(C_TcpSocket *s, C_Packet* p);
void M_SetId(ushort id);
ushort M_Id() const;
void M_Send();
- void M_SendUdp(UdpSocket& s);
+ void M_SendUdp(C_UdpSocket& s);
void M_Time(uint time);
void M_Position(const C_Vec2& v);
const C_Vec2& M_Position() const;
View
@@ -1,5 +1,6 @@
#include <dtglib/Network.h>
#include <Network/Server.h>
+#include <Network/Netcommand.h>
#include <iostream>
#include <signal.h>
View
@@ -7,8 +7,9 @@
int main()
{
- pwskoag::TcpClient c;
- pwskoag::UdpClient u;
+ /*
+ pwskoag::C_TcpClient c;
+ pwskoag::C_UdpClient u;
pwskoag::C_ClientPlayer* p;
pwskoag::C_ClientPlayer fallbackp;
try
@@ -40,4 +41,5 @@ int main()
}
u.M_Disconnect();
c.M_Disconnect();
+ */
}
View
@@ -3,6 +3,7 @@
#include <dtglib/Concurrency.h>
#include <dtglib/Network.h>
#include <Game/ClientPlayer.h>
+#include <Network/Netcommand.h>
using namespace dtglib;
View
@@ -65,13 +65,13 @@ namespace pwskoag
}
}
- static bool M_ParsePacket(C_Packet& p, e_Command header, C_ThreadData* data)
+ static bool M_ParsePacket(C_Packet& p, C_Netcommand::e_Command header, C_ThreadData* data)
{
- C_Mutex* lock=data->lock;
+ C_Mutex* lock=data->m_Lock;
C_Mutex* plrlock=data->m_PlayerLock;
- C_Timer* timer=data->timer;
+ C_Timer* timer=data->m_Timer;
t_Entities* plrs=data->m_Players;
- C_TcpSocket* client=(C_TcpSocket*)data->socket;
+ C_TcpSocket* client=(C_TcpSocket*)data->m_Socket;
if(header==C_Netcommand::Update)
{
@@ -122,9 +122,9 @@ namespace pwskoag
static void TCPReceive(void* args)
{
C_ThreadData* data=(C_ThreadData*)args;
- C_Mutex* lock=data->lock;
- C_TcpSocket* client=(C_TcpSocket*)data->socket;
- bool* stopNow=data->stopNow;
+ C_Mutex* lock=data->m_Lock;
+ C_TcpSocket* client=(C_TcpSocket*)data->m_Socket;
+ bool* stopNow=data->m_StopNow;
C_Selector s;
C_Packet p;
@@ -341,11 +341,12 @@ namespace pwskoag
static void M_NewPlayer(C_Selector& sel, C_Packet& p, const C_IpAddress& ip, ushort port, C_TcpSocket* s, C_UdpSocket* us)
{
+ /*
for(;;)
{
uchar header=0;
p >> header;
- if(header==UDPConnect)
+ if(header==C_Netcommand::Connect)
{
ushort id;
p>>id;
@@ -372,10 +373,12 @@ namespace pwskoag
}
break;
}
+ */
}
static void M_ParsePacket(const C_IpAddress& ip, ushort port, C_Packet& p)
{
+ /*
uchar header=0;
while(p.M_Size())
{
@@ -396,10 +399,12 @@ namespace pwskoag
throw std::runtime_error("Invalid UDP packet header.");
}
}
+ */
}
static void UDPReceive(void* args)
{
+ /*
C_ThreadData* data=static_cast<C_ThreadData*>(args);
C_TcpServer* m_Master=static_cast<C_TcpServer *>(data->m_Void1);
C_UdpSocket* s=static_cast<C_UdpSocket *>(data->socket);
@@ -444,9 +449,11 @@ namespace pwskoag
}
}
}
+ */
}
- C_void UdpServer::M_UpdateGamestate(C_Packet& p)
+ void C_UdpServer::M_UpdateGamestate(C_Packet& p)
{
+ /*
m_Master->M_PlayerLock(true);
t_Entities& plrs=m_Master->M_Players();
for(t_Entities::iterator it=plrs.begin(); it!=plrs.end(); ++it)
@@ -459,10 +466,12 @@ namespace pwskoag
(*it)->M_SendUdp(udpSocket);
}
m_Master->M_PlayerLock(false);
+ */
}
PWSKOAG_API void C_UdpServer::ServerLoop()
{
+ /*
C_ThreadData data(NULL, &m_UdpSocket, NULL, NULL, NULL, NULL, &m_StopNow, m_Master);
C_Thread t(UDPReceive, &data);
C_Packet p;
@@ -471,5 +480,6 @@ namespace pwskoag
M_UpdateGamestate(p);
g_Sleep(TICK_WAITTIME_UDP);
}
+ */
}
}
View
@@ -29,6 +29,9 @@ namespace pwskoag
PWSKOAG_API C_Server(ushort port) : m_StopNow(false), m_ServerPort(port), m_SelfThread(NULL) {};
PWSKOAG_API virtual ~C_Server();
public:
+ static const unsigned int TIMEOUTMS=4000;
+ static const unsigned int TICK_WAITTIME_TCP=250;
+ static const unsigned int TICK_WAITTIME_UDP=33;
PWSKOAG_API virtual void M_Start();
PWSKOAG_API virtual void M_Stop();
PWSKOAG_API virtual void M_ForceStop();
View
@@ -1,7 +1,7 @@
#pragma once
#include "Base.h"
-#include <Player.h>
+#include <Game/Player.h>
namespace pwskoag
{

0 comments on commit 17d7ce3

Please sign in to comment.