Permalink
Browse files

move fake classes to separate directory, cleanup whitesheet.cpp

  • Loading branch information...
1 parent 9251633 commit 672c1294ee01fb2a0987dd151006f24b82782751 @SilverIce committed Jul 8, 2011
View
@@ -12,5 +12,6 @@
# Extensions
!.gitignore
!Movement/*
+!Movement/fake/*
!mov_research/*
!mov_tests/*
View
@@ -1,177 +0,0 @@
-#include "ClientMovement.h"
-#include "UnitMovement.h"
-#include "ObjectGuid.h"
-#include "MovementMessage.h"
-
-#include <sstream>
-
-namespace Movement
-{
- class TimeSyncRequest : public RespHandler
- {
- uint32 reqId;
- public:
-
- TimeSyncRequest(Client * client) : RespHandler(CMSG_TIME_SYNC_RESP), reqId(client->AddRespHandler(this))
- {
- WorldPacket data(SMSG_TIME_SYNC_REQ, 4);
- data << reqId;
- client->SendPacket(data);
- }
-
- virtual void OnReply(Client * client, WorldPacket& data) override
- {
- uint32 client_req_id;
- MSTime client_ticks;
- data >> client_req_id;
- data >> client_ticks;
- if (client_req_id != reqId)
- {
- log_write("TimeSyncRequest::OnReply: wrong counter value: %u and should be: %u", client_req_id, reqId);
- return;
- }
- client->SetClientTime(client_ticks);
- }
- };
-
- void Client::HandleOutcomingMessage(WorldPacket& recv_data)
- {
- if (!m_controlled)
- return;
- ObjectGuid guid;
- ClientMoveState state;
-
- recv_data >> guid.ReadAsPacked();
- recv_data >> state;
-
- QueueState(state);
-
- MovementMessage msg(m_controlled, recv_data.GetOpcode(), recv_data.size());
- msg << guid.WriteAsPacked();
- msg << state;
- BroadcastMessage(msg);
- }
-
- /* For test. if set to true, enables old & wrong time correction */
- static bool old_way = false;
- static bool send_self = false;
-
- static MSTime timestamp_incr = 5000;
- static MSTime timestamp_decr = 0;
-
- void Client::SendMoveMessage(MovementMessage& msg) const
- {
- if (msg.Source() == m_controlled && !send_self)
- return;
-
- // convert original time(server time) to local per-client time
- if (old_way == false)
- msg.CorrectTimeStamp(ServerToClientTime(msg.OrigTime()) + timestamp_incr - timestamp_decr);
- else
- msg.CorrectTimeStamp(ServerTime());
- SendPacket(msg.Packet());
- }
-
- void Client::CleanReferences()
- {
- while(!m_resp_handlers.empty())
- {
- delete m_resp_handlers.back();
- m_resp_handlers.pop_back();
- }
-
- LostControl();
- m_socket = NULL;
- }
-
- void Client::Dereference(const UnitMovement * m)
- {
- if (m != m_controlled || m_controlled->client() != this)
- {
- log_write("wtf?");
- return;
- }
-
- LostControl();
- }
-
- void Client::SetControl(UnitMovement * newly_controlled)
- {
- LostControl();
- m_controlled = newly_controlled;
- m_controlled->client(this);
-
- new TimeSyncRequest(this);
- }
-
- void Client::LostControl()
- {
- if (m_controlled && m_controlled->client() == this)
- m_controlled->client(NULL);
- m_controlled = NULL;
- }
-
- Client::Client(HANDLE socket) :
- m_socket(socket),
- m_controlled(NULL)
- {
- }
-
- void Client::_OnUpdate()
- {
- MSTime now = ServerTime();
-
- if ((now - m_last_sync_time).time > 10000)
- {
- m_last_sync_time = now;
- new TimeSyncRequest(this);
- }
- }
-
- void Client::HandleMoveTimeSkipped(WorldPacket & recv_data)
- {
- ObjectGuid guid;
- int32 time;
- recv_data >> guid.ReadAsPacked();
- recv_data >> time;
- //time_skipped = time;
-
- MovementMessage data(m_controlled, MSG_MOVE_TIME_SKIPPED, 16);
- data << guid.WriteAsPacked();
- data << time;
- BroadcastMessage(data);
- }
-
- std::string Client::ToString() const
- {
- std::stringstream str;
- str << "Server-side time: " << ServerTime().time << " Client-side time: " << ClientTime().time << std::endl;
- str << "Request counter: " << request_counter.getCurrent() << std::endl;
- return str.str();
- }
-
- void Client::HandleResponse(WorldPacket& data)
- {
- if (!m_controlled)
- return;
-
- struct _handler
- {
- Client * client;
- WorldPacket& data;
-
- _handler(Client * c, WorldPacket& _data) : client(c), data(_data) {}
-
- inline bool operator()(RespHandler* hdl)
- {
- if (!hdl->CanHandle(data.GetOpcode()))
- return false;
- hdl->OnReply(client, data);
- delete hdl;
- return true;
- }
- };
-
- m_resp_handlers.erase(std::find_if(m_resp_handlers.begin(),m_resp_handlers.end(),_handler(this,data)));
- }
-}
View
@@ -13,5 +13,5 @@ namespace MaNGOS_API
extern void UpdateMapPosition(WorldObject*, const Movement::Location&);
extern void BroadcastMessage(WorldObject const* obj, Movement::MovementMessage& msg);
extern void BroadcastMessage(WorldObject const* obj, WorldPacket& msg);
- extern void SendPacket(HANDLE socket, const WorldPacket& data);
+ extern void SendPacket(void * socket, const WorldPacket& data);
};
@@ -14,6 +14,11 @@ using Movement::uint32;
using Movement::uint64;
using Movement::int64;
+template<class T>
+struct Unused
+{
+};
+
class ByteBuffer
{
public:
@@ -28,6 +33,8 @@ class ByteBuffer
template<class T> void put(size_t, T&) {}
template<class T> T read(int) { return T();}
template<class T> T read() { return T();}
+ template<class T> void read(T, size_t) {}
+ template<class T> void write(T, size_t) {}
template<class T>
ByteBuffer& operator << (const T&)
@@ -0,0 +1,9 @@
+#include "MaNGOS_API.h"
+
+namespace MaNGOS_API
+{
+ void UpdateMapPosition(WorldObject*, const Movement::Location&) {}
+ void BroadcastMessage(WorldObject const* obj, Movement::MovementMessage& msg) {}
+ void BroadcastMessage(WorldObject const* obj, WorldPacket& msg) {}
+ void SendPacket(void * socket, const WorldPacket& data) {}
+};
@@ -5,6 +5,7 @@
#include "typedefs.h"
#include "ByteBuffer.h"
#include "UpdateFields.h"
+#include "ObjectGuid.h"
using Movement::int8;
using Movement::uint8;
@@ -25,6 +26,10 @@ class WorldObject
{
public:
+ void SetGuidValue(uint32, ObjectGuid) {}
+ ObjectGuid GetGuidValue(uint32) const { return ObjectGuid();}
+ ObjectGuid GetObjectGuid() const { return ObjectGuid();}
+
const ByteBuffer& GetPackGUID() const { return m_packGuid; }
float GetFloatValue(uint16) const { return 0.f;}
@@ -7,6 +7,7 @@ class ObjectGuid
public:
ObjectGuid& ReadAsPacked() { return *this;}
ObjectGuid& WriteAsPacked() { return *this;}
+ uint64 GetRawValue() const { return 0;}
};
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -1,69 +1,10 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include <time.h>
-namespace Movement{
-
- static bool MOV_LOG_FILE_ENABLED = true;
- static bool MOV_LOG_CONSOLE_ENABLED = true;
-
- struct __log_init
- {
- __log_init()
- {
- file = fopen("movement.log","a++");
-
- fprintf(file, "Movement Log\n");
- time_t t;
- time(&t);
- fprintf(file, "Start: %s\n", ctime(&t));
- fflush(file);
- }
-
- ~__log_init()
- {
- time_t t;
- time(&t);
- fprintf(file, "Shutdown: %s\n", ctime(&t));
- fclose(file);
- }
-
- FILE* file;
- } static log;
-
- void log_write(const char* str, ...)
- {
- va_list ap;
+//#include "ace/Stack_Trace.h"
- va_start(ap, str);
- if (MOV_LOG_CONSOLE_ENABLED)
- vfprintf(stdout, str, ap);
- if (MOV_LOG_FILE_ENABLED && log.file)
- vfprintf(log.file, str, ap);
-
- va_end(ap);
-
- if (MOV_LOG_FILE_ENABLED && log.file)
- fprintf(log.file, "\n" );
-
- if (MOV_LOG_CONSOLE_ENABLED)
- printf( "\n" );
-
- fflush(log.file);
- fflush(stdout);
- }
+namespace Movement{
- void log_console(const char* str, ...)
- {
- va_list ap;
- va_start(ap, str);
- vfprintf(stdout, str, ap);
- va_end(ap);
- printf( "\n" );
- fflush(stdout);
- }
}
File renamed without changes.
View
@@ -114,15 +114,15 @@
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="2"
InlineFunctionExpansion="0"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="0"
OmitFramePointers="false"
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..\Movement;..\dep\g3dlite\include\"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;USE_FAKE_CLASSES"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
Oops, something went wrong.

0 comments on commit 672c129

Please sign in to comment.