Quellcode durchsuchen

Merge branch 'master' of http://cutpon.com:3000/devn00b/EQ2EMu

Gogs vor 4 Jahren
Ursprung
Commit
d4ccea24b8

+ 6 - 2
EQ2/source/WorldServer/LoginServer.cpp

@@ -184,8 +184,8 @@ bool LoginServer::Process() {
 			{
 				LogWrite(OPCODE__DEBUG, 1, "Opcode", "Opcode 0x%X (%i): ServerOP_LSFatalError", pack->opcode, pack->opcode);
 
-				LogWrite(WORLD__ERROR, 0, "World", "Login Server returned a fatal error: %s\nDisabling reconnect.", pack->pBuffer);
-				pTryReconnect = false;
+				LogWrite(WORLD__ERROR, 0, "World", "Login Server returned a fatal error: %s\n", pack->pBuffer);
+				tcpc->Disconnect();
 				ret = false;
 				break;
 			}
@@ -448,6 +448,10 @@ bool LoginServer::Process() {
 			}
 		}
 		safe_delete(pack);
+
+		// break out if ret is now false
+		if (!ret)
+			break;
 	}
 	return ret;
 }

+ 3 - 3
EQ2/source/WorldServer/Spawn.cpp

@@ -1783,14 +1783,14 @@ void Spawn::MoveToLocation(Spawn* spawn, float distance, bool immediate){
 	AddRunningLocation(spawn->GetX(), spawn->GetY(), spawn->GetZ(), GetSpeed(), distance);
 }
 
-void Spawn::ProcessMovement(){
+void Spawn::ProcessMovement(bool isSpawnListLocked){
 	if(IsPlayer()){
 		//Check if player is riding a boat, if so update pos (boat's current location + XYZ offsets)
 		Player* player = ((Player*)this);
 		int32 boat_id = player->GetBoatSpawn();
 		Spawn* boat = 0;
 		if(boat_id > 0)
-			boat = GetZone()->GetSpawnByID(boat_id);
+			boat = GetZone()->GetSpawnByID(boat_id, isSpawnListLocked);
 		if(boat){
 			SetX(boat->GetX() + player->GetBoatX());
 			SetY(boat->GetY() + player->GetBoatY());
@@ -1803,7 +1803,7 @@ void Spawn::ProcessMovement(){
 		return;
 
 	MMovementLoop.lock();
-	Spawn* followTarget = GetZone()->GetSpawnByID(m_followTarget);
+	Spawn* followTarget = GetZone()->GetSpawnByID(m_followTarget, isSpawnListLocked);
 	if (!followTarget && m_followTarget > 0)
 		m_followTarget = 0;
 	if (following && followTarget) {

+ 1 - 1
EQ2/source/WorldServer/Spawn.h

@@ -847,7 +847,7 @@ public:
 
 	void	MoveToLocation(Spawn* spawn, float distance, bool immediate = true);
 	void	AddMovementLocation(float x, float y, float z, float speed, int16 delay, const char* lua_function);
-	void	ProcessMovement();
+	void	ProcessMovement(bool isSpawnListLocked=false);
 	void	ResetMovement();
 	bool	IsRunning();
 	void	CalculateRunningLocation(bool stop = false);

+ 1 - 20
EQ2/source/WorldServer/zoneserver.cpp

@@ -1522,7 +1522,7 @@ bool ZoneServer::SpawnProcess(){
 			if (spawn) {
 				// Process spawn movement
 				if (movement) {
-					spawn->ProcessMovement();
+					spawn->ProcessMovement(true);
 					// update last_movement_update for all spawns (used for time_step)
 					spawn->last_movement_update = Timer::GetCurrentTime2();
 				}
@@ -3196,25 +3196,6 @@ void ZoneServer::RemoveMovementNPC(Spawn* spawn){
 		remove_movement_spawns.Add(spawn->GetID());
 }
 
-void ZoneServer::ProcessMovement(){	
-	Spawn* spawn = 0;
-	MutexMap<int32, int32>::iterator itr = movement_spawns.begin();
-	while(itr.Next()){
-		spawn = GetSpawnByID(itr->first);
-		if(spawn) {
-			if(spawn->IsNPC() && !spawn->MovementInterrupted())
-				spawn->ProcessMovement();
-		}
-		else
-			movement_spawns.erase(itr->first);
-	}
-	MutexList<int32>::iterator remove_itr = remove_movement_spawns.begin();
-	while(remove_itr.Next()){
-		movement_spawns.erase(remove_itr->value);
-	}
-	remove_movement_spawns.clear();
-}
-
 void ZoneServer::PlayFlavor(Client* client, Spawn* spawn, const char* mp3, const char* text, const char* emote, int32 key1, int32 key2, int8 language){
 	if(!client || !spawn)
 		return;

+ 0 - 1
EQ2/source/WorldServer/zoneserver.h

@@ -645,7 +645,6 @@ private:
 	void	CheckSpawnScriptTimers();																			// never used outside zone server
 	void	CheckHeadingTimers();																				// never used outside zone server
 	void	RemoveHeadingTimer(Spawn* spawn);																	// never used outside zone server
-	void	ProcessMovement();																					// never used outside zone server
 	void	PrepareSpawnID(Player* player, Spawn* spawn);														// never used outside zone server
 	void	RemoveMovementNPC(Spawn* spawn);																	// never used outside zone server
 	bool	CheckNPCAttacks(NPC* npc, Spawn* victim, Client* client = 0);										// never used outside zone server

+ 2 - 2
EQ2/source/common/EQStream.cpp

@@ -714,14 +714,14 @@ void EQStream::SendPacket(EQProtocolPacket *p)
 	uint32 length;
 
 	// Convert the EQApplicationPacket to 1 or more EQProtocolPackets
-	if (p->size>( MaxLen-6)) { // proto-op(2), app-op(2) ... data ... crc(2)
+	if (p->size>( MaxLen-8)) { // proto-op(2), seq(2), app-op(2) ... data ... crc(2)
 		uchar* tmpbuff=p->pBuffer;
 		length=p->size - 2;
 
 		EQProtocolPacket *out=new EQProtocolPacket(OP_Fragment,NULL,MaxLen-4);
 		*(uint32 *)(out->pBuffer+2)=htonl(length);
-		memcpy(out->pBuffer+6,tmpbuff+2,MaxLen-10);
 		used=MaxLen-10;
+		memcpy(out->pBuffer+6,tmpbuff+2,used);
 
 #ifdef LE_DEBUG
 		LogWrite(PACKET__DEBUG, 0, "Packet", "(%s, %i) New Fragment: ", __FUNCTION__, __LINE__);

+ 53 - 53
EQ2/source/common/Mutex.cpp

@@ -1,21 +1,21 @@
-/*  
-    EQ2Emulator:  Everquest II Server Emulator
-    Copyright (C) 2007  EQ2EMulator Development Team (http://www.eq2emulator.net)
+/*
+	EQ2Emulator:  Everquest II Server Emulator
+	Copyright (C) 2007  EQ2EMulator Development Team (http://www.eq2emulator.net)
 
-    This file is part of EQ2Emulator.
+	This file is part of EQ2Emulator.
 
-    EQ2Emulator is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
+	EQ2Emulator is free software: you can redistribute it and/or modify
+	it under the terms of the GNU General Public License as published by
+	the Free Software Foundation, either version 3 of the License, or
+	(at your option) any later version.
 
-    EQ2Emulator is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+	EQ2Emulator is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with EQ2Emulator.  If not, see <http://www.gnu.org/licenses/>.
+	You should have received a copy of the GNU General Public License
+	along with EQ2Emulator.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "../common/Log.h"
 #include "../common/debug.h"
@@ -40,7 +40,7 @@ Mutex::~Mutex() {
 #endif
 }
 
-void Mutex::SetName(string in_name){
+void Mutex::SetName(string in_name) {
 #ifdef DEBUG
 	name = in_name;
 #endif
@@ -50,10 +50,10 @@ void Mutex::lock() {
 #ifdef DEBUG
 	int i = 0;
 #endif
-	if (name.length() > 0){
-		while (mlocked){
+	if (name.length() > 0) {
+		while (mlocked) {
 #ifdef DEBUG
-			if (i>MUTEX_TIMEOUT_MILLISECONDS){
+			if (i > MUTEX_TIMEOUT_MILLISECONDS) {
 				LogWrite(MUTEX__ERROR, 0, "Mutex", "Possible deadlock attempt by '%s'!", name.c_str());
 				return;
 			}
@@ -75,14 +75,14 @@ void Mutex::unlock() {
 	mlocked = false;
 }
 
-void Mutex::readlock(const char* function, int32 line){
+void Mutex::readlock(const char* function, int32 line) {
 #ifdef DEBUG
 	int32 i = 0;
 #endif
-	while (true){
+	while (true) {
 		//Loop until there isn't a writer, then we can read!
 		CSRead.lock();
-		if (!writing){
+		if (!writing) {
 			readers++;
 			CSRead.unlock();
 #ifdef DEBUG
@@ -95,12 +95,12 @@ void Mutex::readlock(const char* function, int32 line){
 		}
 		CSRead.unlock();
 #ifdef DEBUG
-		if (i > MUTEX_TIMEOUT_MILLISECONDS){
+		if (i > MUTEX_TIMEOUT_MILLISECONDS) {
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The mutex %s called from %s at line %u timed out waiting for a readlock!", name.c_str(), function ? function : "name_not_provided", line);
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The following functions had locks:");
 			map<string, int32>::iterator itr;
 			CSStack.lock();
-			for (itr = stack.begin(); itr != stack.end(); itr++){
+			for (itr = stack.begin(); itr != stack.end(); itr++) {
 				if (itr->second > 0 && itr->first.length() > 0)
 					LogWrite(MUTEX__ERROR, 0, "Mutex", "%s, number of locks = %u", itr->first.c_str(), itr->second);
 			}
@@ -113,7 +113,7 @@ void Mutex::readlock(const char* function, int32 line){
 	}
 }
 
-void Mutex::releasereadlock(const char* function, int32 line){
+void Mutex::releasereadlock(const char* function, int32 line) {
 	//Wait for the readcount lock
 	CSRead.lock();
 	//Lower the readcount by one, when readcount is 0 writers may start writing
@@ -121,10 +121,10 @@ void Mutex::releasereadlock(const char* function, int32 line){
 	CSRead.unlock();
 #ifdef DEBUG
 	CSStack.lock();
-	if (function){
+	if (function) {
 		map<string, int32>::iterator itr = stack.find((string)function);
-		if (itr != stack.end()){
-			if (--(itr->second) == 0){
+		if (itr != stack.end()) {
+			if (--(itr->second) == 0) {
 				stack.erase(itr);
 			}
 		}
@@ -133,10 +133,10 @@ void Mutex::releasereadlock(const char* function, int32 line){
 #endif
 }
 
-bool Mutex::tryreadlock(const char* function){
+bool Mutex::tryreadlock(const char* function) {
 	//This returns true if able to instantly obtain a readlock, false if not
 	CSRead.lock();
-	if (!writing){
+	if (!writing) {
 		readers++;
 		CSRead.unlock();
 	}
@@ -155,24 +155,25 @@ bool Mutex::tryreadlock(const char* function){
 	return true;
 }
 
-void Mutex::writelock(const char* function, int32 line){
+void Mutex::writelock(const char* function, int32 line) {
 	//Wait until the writer lock becomes available, then we can be the only writer!
 #ifdef DEBUG
 	int32 i = 0;
 #endif
-	while (!CSWrite.trylock()){
+	while (!CSWrite.trylock()) {
 #ifdef DEBUG
-		if (i > MUTEX_TIMEOUT_MILLISECONDS){
+		if (i > MUTEX_TIMEOUT_MILLISECONDS) {
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The mutex %s called from %s at line %u timed out waiting on another writelock!", name.c_str(), function ? function : "name_not_provided", line);
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The following functions had locks:");
 			map<string, int32>::iterator itr;
 			CSStack.lock();
-			for (itr = stack.begin(); itr != stack.end(); itr++){
+			for (itr = stack.begin(); itr != stack.end(); itr++) {
 				if (itr->second > 0 && itr->first.length() > 0)
 					LogWrite(MUTEX__ERROR, 0, "Mutex", "%s, number of locks = %u", itr->first.c_str(), itr->second);
 			}
 			CSStack.unlock();
-			return;
+			i = 0;
+			continue;
 		}
 		i++;
 #endif
@@ -187,7 +188,7 @@ void Mutex::writelock(const char* function, int32 line){
 #endif
 }
 
-void Mutex::releasewritelock(const char* function, int32 line){
+void Mutex::releasewritelock(const char* function, int32 line) {
 	//Wait for the readcount lock
 	CSRead.lock();
 	//Readers are aloud again
@@ -197,10 +198,10 @@ void Mutex::releasewritelock(const char* function, int32 line){
 	CSWrite.unlock();
 #ifdef DEBUG
 	CSStack.lock();
-	if (function){
+	if (function) {
 		map<string, int32>::iterator itr = stack.find((string)function);
-		if (itr != stack.end()){
-			if (--(itr->second) == 0){
+		if (itr != stack.end()) {
+			if (--(itr->second) == 0) {
 				stack.erase(itr);
 			}
 		}
@@ -209,14 +210,14 @@ void Mutex::releasewritelock(const char* function, int32 line){
 #endif
 }
 
-bool Mutex::trywritelock(const char* function){
+bool Mutex::trywritelock(const char* function) {
 	//This returns true if able to instantly obtain a writelock, false if not
-	if (CSWrite.trylock()){
+	if (CSWrite.trylock()) {
 		CSRead.lock();
 		if (readers == 0)
 			writing = true;
 		CSRead.unlock();
-		if (!writing){
+		if (!writing) {
 			CSWrite.unlock();
 			return false;
 		}
@@ -240,30 +241,29 @@ void Mutex::waitReaders(const char* function, int32 line)
 #ifdef DEBUG
 	int32 i = 0;
 #endif
-	CSRead.lock();
-	writing = true;
-	CSRead.unlock();
 	while (true)
 	{
 		CSRead.lock();
 		if (readers == 0)
 		{
+			writing = true;
 			CSRead.unlock();
 			break;
 		}
 		CSRead.unlock();
 #ifdef DEBUG
-		if (i > MUTEX_TIMEOUT_MILLISECONDS){
+		if (i > MUTEX_TIMEOUT_MILLISECONDS) {
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The mutex %s called from %s at line %u timed out while waiting on readers!", name.c_str(), function ? function : "name_not_provided", line);
 			LogWrite(MUTEX__ERROR, 0, "Mutex", "The following functions had locks:");
 			map<string, int32>::iterator itr;
 			CSStack.lock();
-			for (itr = stack.begin(); itr != stack.end(); itr++){
+			for (itr = stack.begin(); itr != stack.end(); itr++) {
 				if (itr->second > 0 && itr->first.length() > 0)
 					LogWrite(MUTEX__ERROR, 0, "Mutex", "%s, number of locks = %u", itr->first.c_str(), itr->second);
 			}
 			CSStack.unlock();
-			return;
+			i = 0;
+			continue;
 		}
 		i++;
 #endif
@@ -297,12 +297,12 @@ void LockMutex::lock() {
 	locked = true;
 }
 
-CriticalSection::CriticalSection(int attribute){
+CriticalSection::CriticalSection(int attribute) {
 #ifdef WIN32
 	InitializeCriticalSection(&CSMutex);
 #else
 	pthread_mutexattr_init(&type_attribute);
-	switch(attribute)
+	switch (attribute)
 	{
 	case MUTEX_ATTRIBUTE_FAST:
 		pthread_mutexattr_settype(&type_attribute, PTHREAD_MUTEX_FAST_NP);
@@ -322,7 +322,7 @@ CriticalSection::CriticalSection(int attribute){
 #endif
 }
 
-CriticalSection::~CriticalSection(){
+CriticalSection::~CriticalSection() {
 #ifdef WIN32
 	DeleteCriticalSection(&CSMutex);
 #else
@@ -331,7 +331,7 @@ CriticalSection::~CriticalSection(){
 #endif
 }
 
-void CriticalSection::lock(){
+void CriticalSection::lock() {
 	//Waits for a lock on this critical section
 #ifdef WIN32
 	EnterCriticalSection(&CSMutex);
@@ -340,7 +340,7 @@ void CriticalSection::lock(){
 #endif
 }
 
-void CriticalSection::unlock(){
+void CriticalSection::unlock() {
 	//Gets rid of one of the current thread's locks on this critical section
 #ifdef WIN32
 	LeaveCriticalSection(&CSMutex);
@@ -349,7 +349,7 @@ void CriticalSection::unlock(){
 #endif
 }
 
-bool CriticalSection::trylock(){
+bool CriticalSection::trylock() {
 	//Returns true if able to instantly get a lock on this critical section, false if not
 #ifdef WIN32
 	return TryEnterCriticalSection(&CSMutex);

BIN
server/EQ2Login__Debug.exe


BIN
server/EQ2World__Debug.exe


BIN
server/EQ2World__Debug_x64.exe