Compression needs work but finished the eqstream abstraction layer otherwise.

This commit is contained in:
KimLS 2016-09-25 22:24:28 -07:00
parent 5cad3f62d0
commit 95d4e95400
7 changed files with 27 additions and 41 deletions

View File

@ -144,7 +144,7 @@ void EQStreamIdentifier::Process() {
} //end foreach stream } //end foreach stream
} }
void EQStreamIdentifier::AddStream(std::shared_ptr<EQStreamInterface> &eqs) { void EQStreamIdentifier::AddStream(std::shared_ptr<EQStreamInterface> eqs) {
m_streams.push_back(Record(eqs)); m_streams.push_back(Record(eqs));
eqs = nullptr; eqs = nullptr;
} }

View File

@ -22,7 +22,7 @@ public:
//main processing interface //main processing interface
void Process(); void Process();
void AddStream(std::shared_ptr<EQStreamInterface> &eqs); void AddStream(std::shared_ptr<EQStreamInterface> eqs);
EQStreamInterface *PopIdentified(); EQStreamInterface *PopIdentified();
protected: protected:

View File

@ -900,7 +900,8 @@ void EQ::Net::DaybreakConnection::Decompress(Packet &p, size_t offset, size_t le
new_length = (uint32_t)length - 1; new_length = (uint32_t)length - 1;
} }
else { else {
return; memcpy(new_buffer, buffer, length);
new_length = length;
} }
p.Resize(offset); p.Resize(offset);

View File

@ -120,7 +120,7 @@ EQApplicationPacket *EQ::Net::EQStream::PopPacket() {
} }
EmuOpcode emu_op = (*m_opcode_manager)->EQToEmu(opcode); EmuOpcode emu_op = (*m_opcode_manager)->EQToEmu(opcode);
EQApplicationPacket *ret = new EQApplicationPacket(emu_op, (unsigned char*)p->Data(), p->Length() - m_owner->m_options.opcode_size); EQApplicationPacket *ret = new EQApplicationPacket(emu_op, (unsigned char*)p->Data() + m_owner->m_options.opcode_size, p->Length() - m_owner->m_options.opcode_size);
m_packet_queue.pop_front(); m_packet_queue.pop_front();
return ret; return ret;
} }

View File

@ -75,8 +75,7 @@ namespace EQ
virtual void ReleaseFromUse() { }; virtual void ReleaseFromUse() { };
virtual void RemoveData() { }; virtual void RemoveData() { };
virtual uint32 GetRemoteIP() const; virtual uint32 GetRemoteIP() const;
//the code is dumb and assumes this is in network order... virtual uint16 GetRemotePort() const { return m_connection->RemotePort(); }
virtual uint16 GetRemotePort() const { return EQ::Net::HostToNetwork(m_connection->RemotePort()); }
virtual bool CheckState(EQStreamState state); virtual bool CheckState(EQStreamState state);
virtual std::string Describe() const { return "Direct EQStream"; } virtual std::string Describe() const { return "Direct EQStream"; }
virtual void SetActive(bool val) { } virtual void SetActive(bool val) { }

View File

@ -68,16 +68,11 @@ INSTALL(TARGETS world RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
ADD_DEFINITIONS(-DWORLD) ADD_DEFINITIONS(-DWORLD)
TARGET_LINK_LIBRARIES(world common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY}) TARGET_LINK_LIBRARIES(world common ${PERL_LIBRARY} debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY} libuv fmt)
IF(MSVC) IF(WIN32)
SET_TARGET_PROPERTIES(world PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF") TARGET_LINK_LIBRARIES(world "ws2_32" "psapi" "iphlpapi" "userenv")
TARGET_LINK_LIBRARIES(world "Ws2_32.lib") ENDIF(WIN32)
ENDIF(MSVC)
IF(MINGW)
TARGET_LINK_LIBRARIES(world "WS2_32")
ENDIF(MINGW)
IF(UNIX) IF(UNIX)
TARGET_LINK_LIBRARIES(world "${CMAKE_DL_LIBS}") TARGET_LINK_LIBRARIES(world "${CMAKE_DL_LIBS}")

View File

@ -35,6 +35,9 @@
#include "../common/eqtime.h" #include "../common/eqtime.h"
#include "../common/timeoutmgr.h" #include "../common/timeoutmgr.h"
#include "../common/event/event_loop.h"
#include "../common/net/eqstream.h"
#include "../common/opcodemgr.h" #include "../common/opcodemgr.h"
#include "../common/guilds.h" #include "../common/guilds.h"
#include "../common/eq_stream_ident.h" #include "../common/eq_stream_ident.h"
@ -88,7 +91,6 @@
#include "queryserv.h" #include "queryserv.h"
TimeoutManager timeout_manager; TimeoutManager timeout_manager;
EQStreamFactory eqsf(WorldStream,9000);
EmuTCPServer tcps; EmuTCPServer tcps;
ClientList client_list; ClientList client_list;
GroupLFPList LFPGroupList; GroupLFPList LFPGroupList;
@ -395,12 +397,12 @@ int main(int argc, char** argv) {
Log.Out(Logs::General, Logs::World_Server," %s",errbuf); Log.Out(Logs::General, Logs::World_Server," %s",errbuf);
return 1; return 1;
} }
if (eqsf.Open()) {
Log.Out(Logs::General, Logs::World_Server,"Client (UDP) listener started."); EQ::Net::EQStreamManagerOptions opts(true, false);
} else { opts.daybreak_options.port = 9000;
Log.Out(Logs::General, Logs::World_Server,"Failed to start client (UDP) listener (port 9000)"); opts.opcode_size = 2;
return 1;
} EQ::Net::EQStreamManager eqsm(opts);
//register all the patches we have avaliable with the stream identifier. //register all the patches we have avaliable with the stream identifier.
EQStreamIdentifier stream_identifier; EQStreamIdentifier stream_identifier;
@ -416,20 +418,13 @@ int main(int argc, char** argv) {
EmuTCPConnection* tcpc; EmuTCPConnection* tcpc;
EQStreamInterface *eqsi; EQStreamInterface *eqsi;
eqsm.OnNewConnection([&stream_identifier](std::shared_ptr<EQ::Net::EQStream> stream) {
stream_identifier.AddStream(stream);
Log.OutF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort()));
});
while(RunLoops) { while(RunLoops) {
Timer::SetCurrentTime(); Timer::SetCurrentTime();
//check the factory for any new incoming streams.
while ((eqs = eqsf.Pop())) {
//pull the stream out of the factory and give it to the stream identifier
//which will figure out what patch they are running, and set up the dynamic
//structures and opcodes for that patch.
struct in_addr in;
in.s_addr = eqs->GetRemoteIP();
Log.Out(Logs::Detail, Logs::World_Server, "New connection from IP %s:%d", inet_ntoa(in),ntohs(eqs->GetRemotePort()));
stream_identifier.AddStream(eqs); //takes the stream
}
eqs = nullptr; eqs = nullptr;
//give the stream identifier a chance to do its work.... //give the stream identifier a chance to do its work....
@ -528,11 +523,9 @@ int main(int argc, char** argv) {
} }
} }
if (numclients == 0) {
Sleep(50); EQ::EventLoop::Get().Process();
continue; Sleep(1);
}
Sleep(20);
} }
Log.Out(Logs::General, Logs::World_Server, "World main loop completed."); Log.Out(Logs::General, Logs::World_Server, "World main loop completed.");
Log.Out(Logs::General, Logs::World_Server, "Shutting down console connections (if any)."); Log.Out(Logs::General, Logs::World_Server, "Shutting down console connections (if any).");
@ -541,8 +534,6 @@ int main(int argc, char** argv) {
zoneserver_list.KillAll(); zoneserver_list.KillAll();
Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped."); Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped.");
tcps.Close(); tcps.Close();
Log.Out(Logs::General, Logs::World_Server, "Client (UDP) listener stopped.");
eqsf.Close();
Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop..."); Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop...");
http_server.Stop(); http_server.Stop();
Log.CloseFileLogs(); Log.CloseFileLogs();