Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Release] P4F Game Server Emulator Sources

Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
all last week i try to install shitness MSSQL server -_- .

Windows hopeless system... cant install sql server
 
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
i only cant normaly install any SQL server... My old Sql 2008 R2 stop work. I try to reinstall it... but... i cant delete -_- after some manipulation i delete it, but now cant install -_- . MSSQL 2000 crash when i try to install it
 
Junior Spellweaver
Joined
Aug 3, 2010
Messages
189
Reaction score
20
i only cant normaly install any SQL server... My old Sql 2008 R2 stop work. I try to reinstall it... but... i cant delete -_- after some manipulation i delete it, but now cant install -_- . MSSQL 2000 crash when i try to install it

MSSQL 2000 is not compatible with Windows Server 2008.
 
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
i use Windows 7 x64 and have MSSQL 2000 and 2008 R2. But i cant install it xD
 
Junior Spellweaver
Joined
Aug 1, 2011
Messages
106
Reaction score
52
Info about eDS Crash when full of raven / horses :

Code:
void DGRecvPetItemInfo(SDHP_REQUEST_PETITEM_INFO * aRecv)
{
...
	pRecvPetInfoCount.nCount++;      <-- smthing wrong...

Code:
void CQuery::Close()
{
	SQLCloseCursor(this->m_hStmt);   <- access volation 
	SQLFreeStmt(this->m_hStmt, 2);
	Exec--;
}
 
Last edited:
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
Okey. I reinstall this Windows. Tomorrow i will continue work =).

You need old 0.4.4 sources with GUI?

And you share you fixes?
 
Junior Spellweaver
Joined
Aug 1, 2011
Messages
106
Reaction score
52
i can share my sources but i have verry big problem with a dataserver ;< ...
NPC in CastleSiege are nonworking or Guild when i using a console version of GS ...
when DataServer2 was removed some DS Protocols was removed too.
this is not full eDS... you have to fix this :)




I CAN TRY TO FIX THIS poop!
First Step:

Code:
			case 0x80:
			{
				PMSG_DEFAULT2 * lpDef1 = (PMSG_DEFAULT2 *)aRecv;
				// ----
				switch(lpDef1->subcode)
				{
				case 0x01:
					//GS_DGAnsOwnerGuildMaster((aIndex, CSP_REQ_OWNERGUILDMASTER*)aRecv);
					break;
				case 0x03:
					//GS_DGAnsCastleNpcBuy(aIndex, (CSP_REQ_NPCBUY *)aRecv);
					break;
				case 0x04:
					//GS_DGAnsCastleNpcRepair(aIndex, (CSP_REQ_NPCREPAIR*)aRecv);
					break;
				case 0x05:
					//GS_DGAnsCastleNpcUpgrade(aIndex, (CSP_REQ_NPCUPGRADE*)aRecv);
					break;
				case 0x06:
					//GS_DGAnsTaxInfo(aIndex, (CSP_REQ_TAXINFO*)aRecv);
					break;
				case 0x07:
					//GS_DGAnsTaxRateChange(aIndex, (CSP_REQ_TAXRATECHANGE*)aRecv);
					break;
				case 0x08:
					//GS_DGAnsCastleMoneyChange(aIndex, (CSP_REQ_MONEYCHANGE*)aRecv);
					break;
				case 0x09:
					//GS_DGAnsSiegeDateChange(aIndex, (CSP_REQ_SDEDCHANGE*)aRecv);
					break;
				case 0x0A:
					//GS_DGAnsGuildMarkRegInfo(aIndex, (CSP_REQ_GUILDREGINFO*)aRecv);
					break;
				case 0x0B:
					//GS_DGAnsSiegeEndedChange(aIndex, (CSP_REQ_SIEGEENDCHANGE*)aRecv);
					break;
				case 0x0C:
					//GS_DGAnsCastleOwnerChange(aIndex, (CSP_REQ_CASTLEOWNERCHANGE*)aRecv);
					break;
				case 0x0D:
					//GS_DGAnsRegAttackGuild(aIndex, (CSP_REQ_REGATTACKGUILD*)aRecv);
					break;
				case 0x0E:
					//GS_DGAnsRestartCastleState(aIndex, (CSP_REQ_CASTLESIEGEEND*)aRecv);
					break;
				case 0x0F:
					//GS_DGAnsMapSvrMsgMultiCast(aIndex, (CSP_REQ_MAPSVRMULTICAST*)aRecv);
					break;
				case 0x10:
					//GS_DGAnsRegGuildMark(aIndex, (CSP_REQ_GUILDREGMARK*)aRecv);
					break;
				case 0x11:
					//GS_DGAnsGuildMarkReset(aIndex, (CSP_REQ_GUILDRESETMARK*)aRecv);
					break;
				case 0x12:
					//GS_DGAnsGuildSetGiveUp(aIndex, (CSP_REQ_GUILDSETGIVEUP*)aRecv);
					break;
				case 0x16:
					//GS_DGAnsNpcRemove(aIndex, (CSP_REQ_NPCREMOVE*)aRecv);
					break;
				case 0x17:
					//GS_DGAnsCastleStateSync(aIndex, (CSP_REQ_CASTLESTATESYNC*)aRecv);
					break;
				case 0x18:
					//GS_DGAnsCastleTributeMoney(aIndex, (CSP_REQ_CASTLETRIBUTEMONEY *)aRecv);
					break;
				case 0x19:
					//GS_DGAnsResetCastleTaxInfo(aIndex, (CSP_REQ_RESETCASTLETAXINFO*)aRecv);
					break;
				case 0x1A:
					//GS_DGAnsResetSiegeGuildInfo(aIndex, (CSP_REQ_RESETSIEGEGUILDINFO*)aRecv);
					break;
				case 0x1B:
					//GS_DGAnsResetRegSiegeInfo(aIndex, (CSP_REQ_RESETREGSIEGEINFO *)aRecv);
					break;
				}
			}
			break;

			case 0x81:
				{
					//GS_DGAnsCastleInitData(aIndex, (CSP_REQ_CSINITDATA *)aRecv);
				}
				break;

			case 0x83:
				{
					//GS_DGAnsAllGuildMarkRegInfo(aIndex, (CSP_REQ_ALLGUILDREGINFO*)aRecv);
				}
				break;

			case 0x84:
				{
					//GS_DGAnsFirstCreateNPC(aIndex, (CSP_REQ_NPCSAVEDATA*)aRecv);
				}
				break;

			case 0x85:
				{
					//GS_DGAnsCalcRegGuildList(aIndex, (CSP_REQ_CALCREGGUILDLIST*)aRecv);
				}
				break;

			case 0x86:
				{
					//GS_DGAnsCsGulidUnionInfo(aIndex, (CSP_REQ_CSGUILDUNIONINFO *)aRecv);
				}
				break;

			case 0x87:
				{
					//GS_DGAnsCsSaveTotalGuildInfo(aIndex, (CSP_REQ_CSSAVETOTALGUILDINFO*)aRecv);
				}
				break;

			case 0x88:
				{
					//GS_DGAnsCsLoadTotalGuildInfo(aIndex, (CSP_REQ_CSLOADTOTALGUILDINFO*)aRecv);
				}
				break;

			case 0x89:
				{
					//GS_DGAnsCastleNpcUpdate(aIndex, (CSP_REQ_NPCUPDATEDATA*)aRecv);
				}
				break;

			case 0xB0:
				{
					//DGAnsCrywolfSync(aIndex, (CWP_REQ_CRYWOLFSYNC*)aRecv);
				}
				break;

			case 0xB1:
				{
					//DGAnsCrywolfInfoLoad(aIndex, (CWP_REQ_CRYWOLFINFOLOAD*)aRecv);
				}
				break;


Change to

Code:
			case 0x80:
			{
				PMSG_DEFAULT2 * lpDef1 = (PMSG_DEFAULT2 *)aRecv;
				// ----
				switch(lpDef1->subcode)
				{
				case 0x01:
					GS_DGAnsOwnerGuildMaster((aIndex, CSP_REQ_OWNERGUILDMASTER*)aRecv);
					break;
				case 0x03:
					GS_DGAnsCastleNpcBuy(aIndex, (CSP_REQ_NPCBUY *)aRecv);
					break;
				case 0x04:
					GS_DGAnsCastleNpcRepair(aIndex, (CSP_REQ_NPCREPAIR*)aRecv);
					break;
				case 0x05:
					GS_DGAnsCastleNpcUpgrade(aIndex, (CSP_REQ_NPCUPGRADE*)aRecv);
					break;
				case 0x06:
					GS_DGAnsTaxInfo(aIndex, (CSP_REQ_TAXINFO*)aRecv);
					break;
				case 0x07:
					GS_DGAnsTaxRateChange(aIndex, (CSP_REQ_TAXRATECHANGE*)aRecv);
					break;
				case 0x08:
					GS_DGAnsCastleMoneyChange(aIndex, (CSP_REQ_MONEYCHANGE*)aRecv);
					break;
				case 0x09:
					GS_DGAnsSiegeDateChange(aIndex, (CSP_REQ_SDEDCHANGE*)aRecv);
					break;
				case 0x0A:
					GS_DGAnsGuildMarkRegInfo(aIndex, (CSP_REQ_GUILDREGINFO*)aRecv);
					break;
				case 0x0B:
					GS_DGAnsSiegeEndedChange(aIndex, (CSP_REQ_SIEGEENDCHANGE*)aRecv);
					break;
				case 0x0C:
					GS_DGAnsCastleOwnerChange(aIndex, (CSP_REQ_CASTLEOWNERCHANGE*)aRecv);
					break;
				case 0x0D:
					GS_DGAnsRegAttackGuild(aIndex, (CSP_REQ_REGATTACKGUILD*)aRecv);
					break;
				case 0x0E:
					GS_DGAnsRestartCastleState(aIndex, (CSP_REQ_CASTLESIEGEEND*)aRecv);
					break;
				case 0x0F:
					GS_DGAnsMapSvrMsgMultiCast(aIndex, (CSP_REQ_MAPSVRMULTICAST*)aRecv);
					break;
				case 0x10:
					GS_DGAnsRegGuildMark(aIndex, (CSP_REQ_GUILDREGMARK*)aRecv);
					break;
				case 0x11:
					GS_DGAnsGuildMarkReset(aIndex, (CSP_REQ_GUILDRESETMARK*)aRecv);
					break;
				case 0x12:
					GS_DGAnsGuildSetGiveUp(aIndex, (CSP_REQ_GUILDSETGIVEUP*)aRecv);
					break;
				case 0x16:
					GS_DGAnsNpcRemove(aIndex, (CSP_REQ_NPCREMOVE*)aRecv);
					break;
				case 0x17:
					GS_DGAnsCastleStateSync(aIndex, (CSP_REQ_CASTLESTATESYNC*)aRecv);
					break;
				case 0x18:
					GS_DGAnsCastleTributeMoney(aIndex, (CSP_REQ_CASTLETRIBUTEMONEY *)aRecv);
					break;
				case 0x19:
					GS_DGAnsResetCastleTaxInfo(aIndex, (CSP_REQ_RESETCASTLETAXINFO*)aRecv);
					break;
				case 0x1A:
					GS_DGAnsResetSiegeGuildInfo(aIndex, (CSP_REQ_RESETSIEGEGUILDINFO*)aRecv);
					break;
				case 0x1B:
					GS_DGAnsResetRegSiegeInfo(aIndex, (CSP_REQ_RESETREGSIEGEINFO *)aRecv);
					break;
				}
			}
			break;

			case 0x81:
				{
					GS_DGAnsCastleInitData(aIndex, (CSP_REQ_CSINITDATA *)aRecv);
				}
				break;

			case 0x83:
				{
					GS_DGAnsAllGuildMarkRegInfo(aIndex, (CSP_REQ_ALLGUILDREGINFO*)aRecv);
				}
				break;

			case 0x84:
				{
					GS_DGAnsFirstCreateNPC(aIndex, (CSP_REQ_NPCSAVEDATA*)aRecv);
				}
				break;

			case 0x85:
				{
					GS_DGAnsCalcRegGuildList(aIndex, (CSP_REQ_CALCREGGUILDLIST*)aRecv);
				}
				break;

			case 0x86:
				{
					GS_DGAnsCsGulidUnionInfo(aIndex, (CSP_REQ_CSGUILDUNIONINFO *)aRecv);
				}
				break;

			case 0x87:
				{
					GS_DGAnsCsSaveTotalGuildInfo(aIndex, (CSP_REQ_CSSAVETOTALGUILDINFO*)aRecv);
				}
				break;

			case 0x88:
				{
					GS_DGAnsCsLoadTotalGuildInfo(aIndex, (CSP_REQ_CSLOADTOTALGUILDINFO*)aRecv);
				}
				break;

			case 0x89:
				{
					GS_DGAnsCastleNpcUpdate(aIndex, (CSP_REQ_NPCUPDATEDATA*)aRecv);
				}
				break;

			case 0xB0:
				{
					DGAnsCrywolfSync(aIndex, (CWP_REQ_CRYWOLFSYNC*)aRecv);
				}
				break;

			case 0xB1:
				{
					DGAnsCrywolfInfoLoad(aIndex, (CWP_REQ_CRYWOLFINFOLOAD*)aRecv);
				}
				break;


Next Step:

Code:
//---------------------------------------------------------------------------

void GS_DGAnsOwnerGuildMaster(int aIndex, CSP_REQ_OWNERGUILDMASTER * aRecv)
{
	CSP_ANS_OWNERGUILDMASTER pResult = {0};
	bool bRet						 = false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x01, sizeof(pResult));
	// ----
	pResult.iIndex		= aRecv->iIndex;
	pResult.wMapSvrNum	= aRecv->wMapSvrNum;
	pResult.iResult		= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetOwnerGuildMaster %d",aRecv->wMapSvrNum);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult = g_DbManager.GetInt("QueryResult");
		// ----
		g_DbManager.GetStr("OwnerGuild", pResult.szCastleOwnGuild);
		g_DbManager.GetStr("OwnerGuildMaster", pResult.szCastleOwnGuildMaster);
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleNpcBuy(int aIndex, CSP_REQ_NPCBUY * aRecv)
{
	CSP_ANS_NPCBUY pResult	= {0};
	bool bRet				= false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x03, sizeof(pResult));
	// ----
	pResult.iBuyCost	= aRecv->iBuyCost;
	pResult.iIndex		= aRecv->iIndex;
	pResult.iNpcIndex	= aRecv->iNpcIndex;
	pResult.iNpcNumber	= aRecv->iNpcNumber;
	pResult.wMapSvrNum	= aRecv->wMapSvrNum;
	pResult.iResult		= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcBuy %d,%d,%d,%d,%d,%d,%d,%d,%d,%d",aRecv->wMapSvrNum,aRecv->iNpcNumber,aRecv->iNpcIndex,aRecv->iNpcDfLevel,aRecv->iNpcRgLevel,aRecv->iNpcMaxHp,aRecv->iNpcHp,aRecv->btNpcX,aRecv->btNpcY,aRecv->btNpcDIR);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult = g_DbManager.GetInt("QueryResult");
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleNpcRepair(int aIndex, CSP_REQ_NPCREPAIR * aRecv)
{
	CSP_ANS_NPCREPAIR pResult	= {0};
	bool bRet					= false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x04, sizeof(pResult));
	// ----
	pResult.iIndex		= aRecv->iIndex;
	pResult.iNpcIndex	= aRecv->iNpcIndex;
	pResult.iNpcNumber	= aRecv->iNpcNumber;
	pResult.iRepairCost = aRecv->iRepairCost;
	pResult.wMapSvrNum	= aRecv->wMapSvrNum;
	pResult.iResult		= 0;
	pResult.iNpcMaxHp	= 0;
	pResult.iNpcHpl		= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcRepair %d,%d,%d",aRecv->wMapSvrNum,aRecv->iNpcNumber,aRecv->iNpcIndex);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult		= g_DbManager.GetInt("QueryResult");
		pResult.iNpcHpl		= g_DbManager.GetInt("NPC_HP");
		pResult.iNpcMaxHp	= g_DbManager.GetInt("NPC_MAXHP");
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleNpcUpgrade(int aIndex, CSP_REQ_NPCUPGRADE * aRecv)
{
	CSP_ANS_NPCUPGRADE pResult	= {0};
	bool bRet					= false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x05, sizeof(pResult));
	// ----
	pResult.iIndex		= aRecv->iIndex;
	pResult.iNpcIndex	= aRecv->iNpcIndex;
	pResult.iNpcNumber	= aRecv->iNpcNumber;
	pResult.iNpcUpIndex = aRecv->iNpcUpIndex;
	pResult.iNpcUpType	= aRecv->iNpcUpType;
	pResult.iNpcUpValue = aRecv->iNpcUpValue;
	pResult.wMapSvrNum	= aRecv->wMapSvrNum;
	pResult.iResult		= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcUpgrade %d,%d,%d,%d,%d",aRecv->wMapSvrNum,aRecv->iNpcNumber,aRecv->iNpcIndex,aRecv->iNpcUpType,aRecv->iNpcUpValue);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult = g_DbManager.GetInt("QueryResult");
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsTaxInfo(int aIndex, CSP_REQ_TAXINFO * aRecv)
{
	CSP_ANS_TAXINFO pResult	= {0};
	bool bRet				= false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x06, sizeof(pResult));
	// ----
	pResult.iIndex			= aRecv->iIndex;
	pResult.wMapSvrNum		= aRecv->wMapSvrNum;
	pResult.i64CastleMoney	= 0;
	pResult.iResult			= 0;
	pResult.iTaxHuntZone	= 0;
	pResult.iTaxRateChaos	= 0;
	pResult.iTaxRateStore	= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetCastleTaxInfo %d",aRecv->wMapSvrNum);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult			= 1;
		pResult.i64CastleMoney	= g_DbManager.GetInt64("MONEY");
		pResult.iTaxRateChaos	= g_DbManager.GetInt("TAX_RATE_CHAOS");
		pResult.iTaxRateStore	= g_DbManager.GetInt("TAX_RATE_STORE");
		pResult.iTaxHuntZone	= g_DbManager.GetInt("TAX_HUNT_ZONE");
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsTaxRateChange(int aIndex, CSP_REQ_TAXRATECHANGE * aRecv)
{
	CSP_ANS_TAXRATECHANGE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x07, sizeof(pResult));
	
	pResult.iIndex = aRecv->iIndex;
	pResult.iResult = 0;
	pResult.iTaxKind = aRecv->iTaxKind;
	pResult.iTaxRate = aRecv->iTaxRate;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyTaxRate %d,%d,%d",aRecv->wMapSvrNum,aRecv->iTaxKind,aRecv->iTaxRate);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{			
			pResult.iResult = g_DbManager.GetInt("QueryResult");
			pResult.iTaxKind = g_DbManager.GetInt("TaxKind");
			pResult.iTaxRate = g_DbManager.GetInt("TaxRate");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleMoneyChange(int aIndex, CSP_REQ_MONEYCHANGE * aRecv)
{
	CSP_ANS_MONEYCHANGE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x08, sizeof(pResult));
	
	pResult.i64CastleMoney = 0;
	pResult.iIndex = aRecv->iIndex;
	pResult.iMoneyChanged = aRecv->iMoneyChanged;
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyMoney %d,%d",aRecv->wMapSvrNum,aRecv->iMoneyChanged);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{			
			pResult.iResult = g_DbManager.GetInt("QueryResult");
			pResult.i64CastleMoney = g_DbManager.GetInt64("MONEY");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsSiegeDateChange(int aIndex, CSP_REQ_SDEDCHANGE * aRecv)
{
	CSP_ANS_SDEDCHANGE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x09, sizeof(pResult));
	
	pResult.btEndDay = aRecv->btEndDay;
	pResult.btEndMonth = aRecv->btEndMonth;
	pResult.btStartDay = aRecv->btStartDay;
	pResult.btStartMonth = aRecv->btStartMonth;
	pResult.iIndex = aRecv->iIndex;
	pResult.iResult = 0;
	pResult.wEndYear = aRecv->wEndYear;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	pResult.wStartYear = aRecv->wStartYear;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyCastleSchedule %d, '%d-%d-%d 00:00:00', '%d-%d-%d 00:00:00'",aRecv->wMapSvrNum,aRecv->btStartDay,aRecv->btStartMonth,aRecv->wStartYear,aRecv->btEndDay,aRecv->btEndMonth,aRecv->wEndYear);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{			
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsGuildMarkRegInfo(int aIndex, CSP_REQ_GUILDREGINFO * aRecv)
{
	CSP_ANS_GUILDREGINFO pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0A, sizeof(pResult));
	
	pResult.bIsGiveUp = 0;
	pResult.btRegRank = 0;
	pResult.iIndex = aRecv->iIndex;
	pResult.iRegMarkCount = 0;
	pResult.iResult = 0;
	memcpy(pResult.szGuildName,aRecv->szGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetGuildMarkRegInfo %d, '%s'",aRecv->wMapSvrNum,aRecv->szGuildName);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = 1;
			pResult.iRegMarkCount = g_DbManager.GetInt("REG_MARKS");
			pResult.btRegRank = (BYTE) g_DbManager.GetInt("SEQ_NUM");
			pResult.bIsGiveUp = g_DbManager.GetInt("IS_GIVEUP");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsSiegeEndedChange(int aIndex, CSP_REQ_SIEGEENDCHANGE * aRecv)
{
	CSP_ANS_SIEGEENDCHANGE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0B, sizeof(pResult));
	
	pResult.bIsSiegeEnded = aRecv->bIsSiegeEnded;
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifySiegeEnd %d, %d",aRecv->wMapSvrNum,aRecv->bIsSiegeEnded);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleOwnerChange(int aIndex, CSP_REQ_CASTLEOWNERCHANGE * aRecv)
{
	CSP_ANS_CASTLEOWNERCHANGE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0C, sizeof(pResult));
	
	pResult.bIsCastleOccupied = aRecv->bIsCastleOccupied;
	pResult.iResult = 0;
	memcpy(pResult.szOwnerGuildName,aRecv->szOwnerGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyCastleOwnerInfo %d, %d, '%s'",aRecv->wMapSvrNum,aRecv->bIsCastleOccupied,aRecv->szOwnerGuildName);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsRegAttackGuild(int aIndex, CSP_REQ_REGATTACKGUILD * aRecv)
{
	CSP_ANS_REGATTACKGUILD pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0D, sizeof(pResult));
	
	pResult.iIndex = aRecv->iIndex;
	pResult.iResult = 0;
	memcpy(pResult.szEnemyGuildName,aRecv->szEnemyGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqRegAttackGuild %d, '%s'",aRecv->wMapSvrNum,aRecv->szEnemyGuildName);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsRestartCastleState(int aIndex, CSP_REQ_CASTLESIEGEEND * aRecv)
{
	CSP_ANS_CASTLESIEGEEND pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0E, sizeof(pResult));
	
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ResetCastleSiege %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsMapSvrMsgMultiCast(int aIndex, CSP_REQ_MAPSVRMULTICAST * aRecv)
{
	CSP_ANS_MAPSVRMULTICAST pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x0F, sizeof(pResult));
	
	memcpy(pResult.szMsgText,aRecv->szMsgText,128);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;



	g_ServerManager.DataSendAll((unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsRegGuildMark(int aIndex, CSP_REQ_GUILDREGMARK * aRecv)
{
	CSP_ANS_GUILDREGMARK pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x10, sizeof(pResult));
	
	pResult.iIndex = aRecv->iIndex;
	pResult.iItemPos = aRecv->iItemPos;
	pResult.iRegMarkCount = 0;
	pResult.iResult = 0;
	memcpy(pResult.szGuildName,aRecv->szGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqRegGuildMark %d, '%s'",aRecv->wMapSvrNum,aRecv->szGuildName);
	if (bRet == TRUE )
	{
		if(g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
			pResult.iRegMarkCount = g_DbManager.GetInt("REG_MARKS");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsGuildMarkReset(int aIndex, CSP_REQ_GUILDRESETMARK * aRecv)
{
	CSP_ANS_GUILDRESETMARK pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x11, sizeof(pResult));
	
	pResult.iIndex = aRecv->iIndex;
	pResult.iRegMarkCount = 0;
	pResult.iResult = 0;
	memcpy(pResult.szGuildName,aRecv->szGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyGuildMarkReset %d, '%s'",aRecv->wMapSvrNum,aRecv->szGuildName);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
			pResult.iRegMarkCount = g_DbManager.GetInt("DEL_MARKS");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsGuildSetGiveUp(int aIndex, CSP_REQ_GUILDSETGIVEUP * aRecv)
{
	CSP_ANS_GUILDSETGIVEUP pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x12, sizeof(pResult));
	
	pResult.bIsGiveUp = aRecv->bIsGiveUp;
	pResult.iIndex = aRecv->iIndex;
	pResult.iRegMarkCount = 0;
	pResult.iResult = 0;
	memcpy(pResult.szGuildName,aRecv->szGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ModifyGuildGiveUp %d, '%s', %d",aRecv->wMapSvrNum,aRecv->szGuildName,aRecv->bIsGiveUp);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
			pResult.iRegMarkCount = g_DbManager.GetInt("DEL_MARKS");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsNpcRemove(int aIndex, CSP_REQ_NPCREMOVE * aRecv)
{
	CSP_ANS_NPCREMOVE pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x16, sizeof(pResult));
	
	pResult.iNpcIndex = aRecv->iNpcIndex;
	pResult.iNpcNumber = aRecv->iNpcNumber;
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcRemove %d, %d, %d",aRecv->wMapSvrNum,aRecv->iNpcNumber,aRecv->iNpcIndex);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleStateSync(int aIndex, CSP_REQ_CASTLESTATESYNC * aRecv)
{
	CSP_ANS_CASTLESTATESYNC pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x17, sizeof(pResult));
	
	pResult.iCastleState = aRecv->iCastleState;
	pResult.iTaxHuntZone = aRecv->iTaxHuntZone;
	pResult.iTaxRateChaos = aRecv->iTaxRateChaos;
	pResult.iTaxRateStore = aRecv->iTaxRateStore;
	memcpy(pResult.szOwnerGuildName,aRecv->szOwnerGuildName,8);
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	g_ServerManager.DataSendAll((unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleTributeMoney(int aIndex, CSP_REQ_CASTLETRIBUTEMONEY * aRecv)
{
	CSP_ANS_CASTLETRIBUTEMONEY pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x18, sizeof(pResult));
	
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC EXEC WZ_CS_ModifyMoney %d, %d",aRecv->wMapSvrNum,aRecv->iCastleTributeMoney);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsResetCastleTaxInfo(int aIndex, CSP_REQ_RESETCASTLETAXINFO * aRecv)
{
	CSP_ANS_RESETCASTLETAXINFO pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x19, sizeof(pResult));
	
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ResetCastleTaxInfo %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsResetSiegeGuildInfo(int aIndex, CSP_REQ_RESETSIEGEGUILDINFO * aRecv)
{
	CSP_ANS_RESETSIEGEGUILDINFO pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x1A, sizeof(pResult));
	
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ResetSiegeGuildInfo %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsResetRegSiegeInfo(int aIndex, CSP_REQ_RESETREGSIEGEINFO * aRecv)
{
	CSP_ANS_RESETREGSIEGEINFO pResult;
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x1B, sizeof(pResult));
	
	pResult.iResult = 0;
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ResetRegSiegeInfo %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.iResult = g_DbManager.GetInt("QueryResult");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleInitData(int aIndex, CSP_REQ_CSINITDATA * aRecv)
{
	BOOL bRet = FALSE;
	int Counter = 0;

	
	char cBUFFER[10000]={0};

	CSP_ANS_CSINITDATA * pResult = (CSP_ANS_CSINITDATA *)(cBUFFER);
	CSP_CSINITDATA * NPCInfo = (CSP_CSINITDATA *)(cBUFFER + sizeof(CSP_ANS_CSINITDATA));
	
	pResult->btEndDay = 0;
	pResult->btEndMonth = 0;
	pResult->btIsCastleOccupied = 0;
	pResult->btIsSiegeEnded = 0;
	pResult->btIsSiegeGuildList = 0;
	pResult->btStartDay = 0;
	pResult->btStartMonth = 0;
	pResult->i64CastleMoney = 0;
	pResult->iCount = 0;
	pResult->iFirstCreate = 0;
	pResult->iResult  = 0;
	pResult->iTaxHuntZone = 0;
	pResult->iTaxRateChaos = 0;
	pResult->iTaxRateStore = 0;
	memset(pResult->szCastleOwnGuild,0,8);
	//memcpy(pResult->szCastleOwnGuild,0,8);
	pResult->wEndYear = 0;
	pResult->wMapSvrNum = aRecv->wMapSvrNum;
	pResult->wStartYear = 0;
	
	int lOfs=sizeof(CSP_ANS_CSINITDATA);

	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetCastleTotalInfo %d,%d",aRecv->wMapSvrNum,aRecv->iCastleEventCycle);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult->iResult = 1;
			pResult->btEndDay = g_DbManager.GetInt("EDAY");
			pResult->btEndMonth = g_DbManager.GetInt("EMONTH");
			pResult->btIsCastleOccupied = g_DbManager.GetInt("CASLE_OCCUPY");
			pResult->btIsSiegeEnded = g_DbManager.GetInt("SIEGE_ENDED");
			pResult->btIsSiegeGuildList = g_DbManager.GetInt("SIEGE_GUILDLIST_SETTED");
			pResult->btStartDay = g_DbManager.GetInt("SDAY");
			pResult->btStartMonth = g_DbManager.GetInt("SMONTH");
			pResult->i64CastleMoney = g_DbManager.GetInt64("MONEY");
			pResult->iFirstCreate = g_DbManager.GetInt("FIRST_CREATE");
			pResult->iTaxHuntZone = g_DbManager.GetInt("TAX_RATE_ZONE");
			pResult->iTaxRateChaos = g_DbManager.GetInt("TAX_RATE_CHAOS");
			pResult->iTaxRateStore = g_DbManager.GetInt("TAX_RATE_STORE");
			g_DbManager.GetStr("OWNER_GUILD", pResult->szCastleOwnGuild);
			pResult->wEndYear = g_DbManager.GetInt("EYEAR");
			pResult->wStartYear = g_DbManager.GetInt("SYEAR");
			g_DbManager.Clear();

			bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetCastleNpcInfo %d",aRecv->wMapSvrNum);
			if (bRet == TRUE )
			{
				if( g_DbManager.Fetch() != SQL_NO_DATA)
				{
					do
					{
						NPCInfo = (CSP_CSINITDATA *)(cBUFFER + lOfs);
						NPCInfo->iNpcNumber = g_DbManager.GetInt("NPC_NUMBER");
						NPCInfo->iNpcIndex = g_DbManager.GetInt("NPC_INDEX");
						NPCInfo->iNpcDfLevel = g_DbManager.GetInt("NPC_DF_LEVEL");
						NPCInfo->iNpcRgLevel = g_DbManager.GetInt("NPC_RG_LEVEL");
						NPCInfo->iNpcMaxHp = g_DbManager.GetInt("NPC_MAXHP");
						NPCInfo->iNpcHp = g_DbManager.GetInt("NPC_HP");
						NPCInfo->btNpcX = g_DbManager.GetInt("NPC_X");
						NPCInfo->btNpcY = g_DbManager.GetInt("NPC_Y");
						NPCInfo->btNpcDIR = g_DbManager.GetInt("NPC_DIR");
						lOfs+=sizeof(CSP_CSINITDATA);
						Counter++;
					}while(Counter < 200 && g_DbManager.Fetch() != SQL_NO_DATA);
				}
			}
		}
	}
	g_DbManager.Clear();
	PHeadSetW((LPBYTE)pResult, 0x81, sizeof(CSP_ANS_CSINITDATA) + sizeof(CSP_CSINITDATA) * Counter);
	pResult->iCount = Counter;
	g_ServerManager.DataSend(aIndex, (unsigned char*)cBUFFER, sizeof(CSP_ANS_CSINITDATA) + sizeof(CSP_CSINITDATA) * Counter);
}
//---------------------------------------------------------------------------

void GS_DGAnsAllGuildMarkRegInfo(int aIndex, CSP_REQ_ALLGUILDREGINFO * aRecv)
{
	char cBUFFER[10000]={0};

	CSP_ANS_ALLGUILDREGINFO * pResult = (CSP_ANS_ALLGUILDREGINFO *)(cBUFFER);
	CSP_GUILDREGINFO * GuildInfo = (CSP_GUILDREGINFO *)(cBUFFER + sizeof(CSP_ANS_ALLGUILDREGINFO));
	int Counter = 0;

	pResult->iIndex = aRecv->iIndex;
	pResult->iResult = 1;
	pResult->wMapSvrNum = aRecv->wMapSvrNum;
	GuildInfo->iRegMarkCount = 0;
	GuildInfo->btRegRank = 0;
	GuildInfo->bIsGiveUp = 0;
	memset(GuildInfo->szGuildName,0,8);
	//memcpy(GuildInfo->szGuildName,0,8);
	
	int lOfs=sizeof(CSP_ANS_ALLGUILDREGINFO);

	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetAllGuildMarkRegInfo %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{
			do
			{
				GuildInfo = (CSP_GUILDREGINFO *)(cBUFFER + lOfs);
				char tmp[8]={0};
				GuildInfo->bIsGiveUp = g_DbManager.GetInt("IS_GUIVEUP");
				GuildInfo->btRegRank = (BYTE) g_DbManager.GetInt("SEQ_NUM");
				GuildInfo->iRegMarkCount = g_DbManager.GetInt("REG_MARKS");
				g_DbManager.GetStr("REG_SIEGE_GUILD", tmp);
				memcpy(GuildInfo->szGuildName,tmp,8);
				Counter++;
				lOfs+=sizeof(CSP_GUILDREGINFO);
			}while(Counter < 100 && g_DbManager.Fetch() != SQL_NO_DATA);
		}
	}
	g_DbManager.Clear();
	PHeadSetW((LPBYTE)pResult, 0x83, sizeof(CSP_ANS_ALLGUILDREGINFO) + sizeof(CSP_GUILDREGINFO) * Counter);
	pResult->iCount = Counter;
	g_ServerManager.DataSend(aIndex, (unsigned char*)cBUFFER, sizeof(CSP_ANS_ALLGUILDREGINFO) + sizeof(CSP_GUILDREGINFO) * Counter);
}
//---------------------------------------------------------------------------

void GS_DGAnsFirstCreateNPC(int aIndex, CSP_REQ_NPCSAVEDATA * aRecv)
{
	int Counter = 0;
	BOOL bRet = FALSE;
	CSP_ANS_NPCSAVEDATA pResult;
	PHeadSetB((LPBYTE)&pResult, 0x84, sizeof(pResult));
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	pResult.iResult = 0;

	int lOfs=sizeof(CSP_REQ_NPCSAVEDATA);

	bRet = g_DbManager.ExecFormat("DELETE FROM MuCastle_NPC WHERE MAP_SVR_GROUP = %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if(aRecv->iCount > 0)
		{
			while(Counter<aRecv->iCount)
			{
				g_DbManager.Clear();
				CSP_NPCSAVEDATA * NPCInfo = (CSP_NPCSAVEDATA*)((LPBYTE)aRecv + lOfs);
				bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcBuy %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",aRecv->wMapSvrNum,NPCInfo->iNpcNumber,NPCInfo->iNpcIndex,NPCInfo->iNpcDfLevel,NPCInfo->iNpcRgLevel,NPCInfo->iNpcMaxHp,NPCInfo->iNpcHp,NPCInfo->btNpcX,NPCInfo->btNpcY,NPCInfo->btNpcDIR);
				if (bRet != TRUE )
				{
					g_DbManager.Clear();
					break;
				}
				Counter++;
				lOfs+=sizeof(CSP_NPCSAVEDATA);
			}
			pResult.iResult = 1;
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult,sizeof(pResult));
}
//---------------------------------------------------------------------------

void GS_DGAnsCalcRegGuildList(int aIndex, CSP_REQ_CALCREGGUILDLIST * aRecv)
{
	char cBUFFER[10000]={0};

	CSP_ANS_CALCREGGUILDLIST * pResult = (CSP_ANS_CALCREGGUILDLIST *)(cBUFFER);
	CSP_CALCREGGUILDLIST * GuildInfo = (CSP_CALCREGGUILDLIST *)(cBUFFER + sizeof(CSP_ANS_CALCREGGUILDLIST));
	int Counter = 0;

	pResult->iResult = 1;
	pResult->wMapSvrNum = aRecv->wMapSvrNum;
	GuildInfo->iGuildMasterLevel = 0;
	GuildInfo->iGuildMemberCount = 0;
	GuildInfo->iRegMarkCount = 0;
	GuildInfo->iSeqNum = 0;
	memset(GuildInfo->szGuildName,0,8);
	//memcpy(GuildInfo->szGuildName,0,8);
	
	int lOfs=sizeof(CSP_ANS_CALCREGGUILDLIST);

	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetCalcRegGuildList %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{
			do
			{
				GuildInfo = (CSP_CALCREGGUILDLIST *)(cBUFFER + lOfs);
				char tmp[8]={0};
				GuildInfo->iGuildMasterLevel = g_DbManager.GetInt("GM_LEVEL");
				GuildInfo->iGuildMemberCount = g_DbManager.GetInt("GUILD_MEMBER");
				GuildInfo->iRegMarkCount = g_DbManager.GetInt("REG_MARKS");
				GuildInfo->iSeqNum = g_DbManager.GetInt("SEQ_NUM");
				g_DbManager.GetStr("REG_SIEGE_GUILD", tmp);
				memcpy(GuildInfo->szGuildName,tmp,8);
				Counter++;
				lOfs+=sizeof(CSP_CALCREGGUILDLIST);
			}while(Counter < 100 && g_DbManager.Fetch() != SQL_NO_DATA);
		}
	}
	g_DbManager.Clear();
	PHeadSetW((LPBYTE)pResult, 0x85, sizeof(CSP_ANS_CALCREGGUILDLIST) + sizeof(CSP_CALCREGGUILDLIST) * Counter);
	pResult->iCount = Counter;
	g_ServerManager.DataSend(aIndex, (unsigned char*)cBUFFER, sizeof(CSP_ANS_CALCREGGUILDLIST) + sizeof(CSP_CALCREGGUILDLIST) * Counter);
}
//---------------------------------------------------------------------------

void GS_DGAnsCsGulidUnionInfo(int aIndex, CSP_REQ_CSGUILDUNIONINFO * aRecv)
{
	int Counter = 0;
	int GuildCount = 0;
	char cBUFFER[10000]={0};

	CSP_ANS_CSGUILDUNIONINFO * pResult = (CSP_ANS_CSGUILDUNIONINFO *)(cBUFFER);
	CSP_CSGUILDUNIONINFO * GuildInfo = (CSP_CSGUILDUNIONINFO *)(cBUFFER + sizeof(CSP_ANS_CSGUILDUNIONINFO));

	PHeadSetB((LPBYTE)pResult, 0x86, sizeof(pResult));
	pResult->wMapSvrNum = aRecv->wMapSvrNum;
	pResult->iResult = 0;
	pResult->iCount = 0;

	int lOfs=sizeof(CSP_REQ_CSSAVETOTALGUILDINFO);
	int ROfs=lOfs;

	if(aRecv->iCount > 0)
	{
		while(Counter<aRecv->iCount)
		{
			CSP_CSGUILDUNIONINFO * GuildRecvInfo = (CSP_CSGUILDUNIONINFO*)((LPBYTE)aRecv + lOfs);
			BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetCsGuildUnionInfo '%s'",GuildRecvInfo->szGuildName);
			
			if(( g_DbManager.Fetch() != SQL_NO_DATA) && (bRet != TRUE ))
			{
				g_DbManager.Clear();
				break;
			}
			
			do
			{
				GuildInfo = (CSP_CSGUILDUNIONINFO *)(cBUFFER + ROfs);
				char tmp[8]={0};
				g_DbManager.GetStr("GUILD_NAME", tmp);
				memcpy(GuildInfo->szGuildName,tmp,8);
				GuildInfo->iCsGuildID = GuildCount;
				GuildCount++;
				ROfs+=sizeof(CSP_CALCREGGUILDLIST);
			}while(GuildCount < 100 && g_DbManager.Fetch() != SQL_NO_DATA);
			g_DbManager.Clear();

			Counter++;
			lOfs+=sizeof(CSP_CSGUILDUNIONINFO);
		}
		pResult->iResult = 1;
	}
	PHeadSetW((LPBYTE)pResult, 0x86, sizeof(CSP_ANS_CSGUILDUNIONINFO) + sizeof(CSP_CSGUILDUNIONINFO) * GuildCount);
	pResult->iCount = Counter;
	g_ServerManager.DataSend(aIndex, (unsigned char*)cBUFFER, sizeof(CSP_ANS_CSGUILDUNIONINFO) + sizeof(CSP_CSGUILDUNIONINFO) * GuildCount);
}
//---------------------------------------------------------------------------

void GS_DGAnsCsSaveTotalGuildInfo(int aIndex, CSP_REQ_CSSAVETOTALGUILDINFO * aRecv)
{
	int Counter = 0;
	CSP_ANS_CSSAVETOTALGUILDINFO pResult;
	PHeadSetB((LPBYTE)&pResult, 0x87, sizeof(pResult));
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	pResult.iResult = 0;

	int lOfs=sizeof(CSP_REQ_CSSAVETOTALGUILDINFO);

	if(aRecv->iCount > 0)
	{
		while(Counter<aRecv->iCount)
		{
			CSP_CSSAVETOTALGUILDINFO * GuildInfo = (CSP_CSSAVETOTALGUILDINFO*)((LPBYTE)aRecv + lOfs);
			BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_SetSiegeGuildInfo %d, '%s', %d, %d",aRecv->wMapSvrNum,GuildInfo->szGuildName,GuildInfo->iCsGuildID,GuildInfo->iGuildInvolved);
			if (bRet != TRUE )
			{
				g_DbManager.Clear();
				break;
			}
			g_DbManager.Clear();
			Counter++;
			lOfs+=sizeof(CSP_CSSAVETOTALGUILDINFO);
		}
		pResult.iResult = 1;
	}
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult,sizeof(pResult));
}
//---------------------------------------------------------------------------

void GS_DGAnsCsLoadTotalGuildInfo(int aIndex, CSP_REQ_CSLOADTOTALGUILDINFO * aRecv)
{
	char cBUFFER[10000]={0};

	CSP_ANS_CSLOADTOTALGUILDINFO * pResult = (CSP_ANS_CSLOADTOTALGUILDINFO *)(cBUFFER);
	CSP_CSLOADTOTALGUILDINFO * GuildInfo = (CSP_CSLOADTOTALGUILDINFO *)(cBUFFER + sizeof(CSP_ANS_CSLOADTOTALGUILDINFO));
	int Counter = 0;

	pResult->iResult = 1;
	pResult->wMapSvrNum = aRecv->wMapSvrNum;
	GuildInfo->iCsGuildID = 0;
	GuildInfo->iGuildInvolved = 0;
	memset(GuildInfo->szGuildName,0,8);
	//memcpy(GuildInfo->szGuildName,0,8);
	
	int lOfs=sizeof(CSP_ANS_CSLOADTOTALGUILDINFO);

	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetSiegeGuildInfo %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{
			do
			{
				GuildInfo = (CSP_CSLOADTOTALGUILDINFO *)(cBUFFER + lOfs);
				char tmp[8]={0};
				GuildInfo->iCsGuildID = g_DbManager.GetInt("GUILD_ID");
				GuildInfo->iGuildInvolved = g_DbManager.GetInt("GUILD_INVOLVED");
				g_DbManager.GetStr("GUILD_NAME", tmp);
				memcpy(GuildInfo->szGuildName,tmp,8);
				Counter++;
				lOfs+=sizeof(CSP_CSLOADTOTALGUILDINFO);
			}while(Counter < 100 && g_DbManager.Fetch() != SQL_NO_DATA);
		}
	}
	g_DbManager.Clear();
	PHeadSetW((LPBYTE)pResult, 0x88, sizeof(CSP_ANS_CSLOADTOTALGUILDINFO) + sizeof(CSP_CSLOADTOTALGUILDINFO) * Counter);
	pResult->iCount = Counter;
	g_ServerManager.DataSend(aIndex, (unsigned char*)cBUFFER, sizeof(CSP_ANS_CSLOADTOTALGUILDINFO) + sizeof(CSP_CSLOADTOTALGUILDINFO) * Counter);
}
//---------------------------------------------------------------------------

void GS_DGAnsCastleNpcUpdate(int aIndex, CSP_REQ_NPCUPDATEDATA * aRecv)
{
	int Counter = 0;
	CSP_ANS_NPCUPDATEDATA pResult;
	PHeadSetB((LPBYTE)&pResult, 0x89, sizeof(pResult));
	pResult.wMapSvrNum = aRecv->wMapSvrNum;
	pResult.iResult = 0;
	BOOL bRet = FALSE;

	int lOfs=sizeof(CSP_REQ_NPCUPDATEDATA);

	bRet = g_DbManager.ExecFormat("DELETE FROM MuCastle_NPC WHERE MAP_SVR_GROUP = %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if(aRecv->iCount > 0)
		{
			while(Counter<aRecv->iCount)
			{
				g_DbManager.Clear();
				CSP_NPCUPDATEDATA * NPCInfo = (CSP_NPCUPDATEDATA*)((LPBYTE)aRecv + lOfs);
				bRet = g_DbManager.ExecFormat("EXEC WZ_CS_ReqNpcUpdate %d, %d, %d, %d, %d, %d, %d, %d, %d, %d",aRecv->wMapSvrNum,NPCInfo->iNpcNumber,NPCInfo->iNpcIndex,NPCInfo->iNpcDfLevel,NPCInfo->iNpcRgLevel,NPCInfo->iNpcMaxHp,NPCInfo->iNpcHp,NPCInfo->btNpcX,NPCInfo->btNpcY,NPCInfo->btNpcDIR);
				if (bRet != TRUE )
				{
					g_DbManager.Clear();
					break;
				}
				Counter++;
				lOfs+=sizeof(CSP_NPCUPDATEDATA);
			}
			pResult.iResult = 1;
		}
	}
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult,sizeof(pResult));
}
//---------------------------------------------------------------------------

void DGAnsCrywolfSync(int aIndex, CWP_REQ_CRYWOLFSYNC * aRecv)
{
	CWP_ANS_CRYWOLFSYNC pResult;
	PHeadSetB((LPBYTE)&pResult, 0xB0, sizeof(pResult));
	pResult.iCrywolfState = aRecv->iCrywolfState;
	pResult.iOccupationState = aRecv->iOccupationState;
	pResult.btResult = aRecv->iOccupationState;	//REVEER

	g_ServerManager.DataSendAll((unsigned char*)&pResult,sizeof(pResult));
}
//---------------------------------------------------------------------------

void DGAnsCrywolfInfoLoad(int aIndex, CWP_REQ_CRYWOLFINFOLOAD * aRecv)
{
	CWP_ANS_CRYWOLFINFOLOAD pResult;
	PHeadSetB((LPBYTE)&pResult, 0xB1, sizeof(pResult));
	
	pResult.btResult = 0;
	pResult.iCrywolfState = 0;
	pResult.iOccupationState = 0;
	
	BOOL bRet = g_DbManager.ExecFormat("EXEC WZ_CW_InfoLoad %d",aRecv->wMapSvrNum);
	if (bRet == TRUE )
	{
		if( g_DbManager.Fetch() != SQL_NO_DATA)
		{	
			pResult.btResult = 1;
			pResult.iCrywolfState = g_DbManager.GetInt("CRYWOLF_STATE");
			pResult.iOccupationState = g_DbManager.GetInt("CRYWOLF_OCCUFY");
		}
	}
	g_DbManager.Clear();
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}
//---------------------------------------------------------------------------


hmmm... GS_DGAnsOwnerGuildMaster ? Orginal:

Code:
void GS_DGAnsOwnerGuildMaster(int aIndex, CSP_REQ_OWNERGUILDMASTER * aRecv)
{
	CSP_ANS_OWNERGUILDMASTER pResult = {0};
	bool bRet						 = false;
	// ----
	PHeadSubSetB((LPBYTE)&pResult, 0x80,0x01, sizeof(pResult));
	// ----
	pResult.iIndex		= aRecv->iIndex;
	pResult.wMapSvrNum	= aRecv->wMapSvrNum;
	pResult.iResult		= 0;
	// ----
	bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetOwnerGuildMaster %d",aRecv->wMapSvrNum);
	// ----
	if ((bRet == true) && (g_DbManager.Fetch() != SQL_NO_DATA))
	{
		pResult.iResult = g_DbManager.GetInt("QueryResult");
		// ----
		g_DbManager.GetStr("OwnerGuild", pResult.szCastleOwnGuild);
		g_DbManager.GetStr("OwnerGuildMaster", pResult.szCastleOwnGuildMaster);
	}
	// ----
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}


WHAT I NEED TO CHANGE IN ORGINAL SRC TO MAKE THIS CODE USABLE?

1. we need to compare sources

P4F:

Code:
void DataServerLogin(SDHP_SERVERINFO * lpMsg)
{
boost::shared_ptr<SDHP_RESULT> pResult(new SDHP_RESULT);

pResult->h.c = 0xC1; 
pResult->h.headcode = 0x00;
pResult->h.size = sizeof(SDHP_RESULT);

pResult->Result = 1;

#ifdef DB_TYPE
if ( MySQL.Execute("SELECT ItemCount FROM GameServerInfo WHERE Number=0") == TRUE )
{
pResult->ItemCount = MySQL.GetAsInteger("ItemCount");
}
MySQL.Close();
#else
if ( g_MuOnlineDB.ExecQuery("SELECT ItemCount FROM GameServerInfo WHERE Number=0") == TRUE )
{
if (g_MuOnlineDB.Fetch() != SQL_NO_DATA)
pResult->ItemCount = g_MuOnlineDB.GetAsInteger("ItemCount");
}

g_MuOnlineDB.Close();
#endif

AsyncWrite(pResult, pResult->h.size);
}

Original:

Code:
void DataServerLogin(int aIndex, SDHP_SERVERINFO * lpMsg)
{
	SDHP_RESULT pResult = {0};
	// ----
	PHeadSetB((LPBYTE)&pResult, 0x00, sizeof(pResult));
	pResult.Result = 1;
	// ----
	if(g_DbManager.ExecFormat("SELECT ItemCount FROM GameServerInfo WHERE Number=0") == true)
	{
		g_DbManager.Fetch();
		// ----
		pResult.ItemCount = g_DbManager.GetInt("ItemCount");
	}
	g_DbManager.Clear();
	// ----
	g_ServerManager.DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
}


Code:
bRet = g_DbManager.ExecFormat("EXEC WZ_CS_GetOwnerGuildMaster %d",aRecv->wMapSvrNum);

change to

Code:
	stringstream str;
	str.str("");
	str<<"EXEC WZ_CS_GetOwnerGuildMaster '"<<aRecv->wMapSvrNum;
	g_MuOnlineDB.ExecQuery(str.str().c_str());
	g_MuOnlineDB.Close();
I DONT KNOW ! ! !
 
Last edited:
Newbie Spellweaver
Joined
Oct 3, 2009
Messages
33
Reaction score
25
Maybe its not important .. but

JewelMixSystem.cpp - >
BOOL CJewelMixSystem::UnMixJewel - >

for ( int x=0;x<(MAIN_INVENTORY_SIZE-INVETORY_WEAR_SIZE);x++)

correctly

for ( int x=INVETORY_WEAR_SIZE;x<MAIN_INVENTORY_SIZE;x++)
 
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
Hello to all. I Have another strong problems with OS. If anyone want to join to SVN - tell me. But i will check all code what you write :)
 
Junior Spellweaver
Joined
Aug 1, 2011
Messages
106
Reaction score
52
JewelMixSystem.cpp - >
BOOL CJewelMixSystem::UnMixJewel - >

for ( int x=0;x<(MAIN_INVENTORY_SIZE-INVETORY_WEAR_SIZE);x++)

correctly

for ( int x=INVETORY_WEAR_SIZE;x<MAIN_INVENTORY_SIZE;x++)

- can you explain me why ? : )
 
Newbie Spellweaver
Joined
Jul 7, 2005
Messages
34
Reaction score
11
because
Inventory = Wear Slots (ex: Set, Weapon, jewelery) + Bag Slots
and you maybe want iterate through Bag Slots
 
Junior Spellweaver
Joined
Aug 1, 2011
Messages
106
Reaction score
52
Ohh x=INVETORY_WEAR_SIZE will be end of INVETORY_WEAR_SIZE ?
PL: Dzięki! :D
 
Last edited:
Newbie Spellweaver
Joined
Jun 12, 2005
Messages
63
Reaction score
12
I found 1 bugs. Nightmare Event - don't kill Nightmare Event and Display Success without kill Boss.
I search more.
 
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
finally i install MSSQL =))) so soon will be updates
 
Initiate Mage
Joined
Sep 12, 2011
Messages
4
Reaction score
0
I found 1 bugs. Nightmare Event - don't kill Nightmare Event and Display Success without kill Boss.
I search more.

open Kanturu.dat and change it:

PHP:
// State:	State Condition of Event Start
// Condition:	Condition End ( 0 - no condition / 1 - time )
// Value:	Time Value

//=========================================================================
//   [State]  [Cond]  [Value]
//=========================================================================
0
	0	0	0	// None
	1	0	0	// Battle Standby
	2	0	0	// Battle Of Maya
	3	0	0	// Battle Of NightMare
	4	0	0	// Tower Of Refinement
	5	1	0	// End
end

//=========================================================================
// Preparation for the Battle of Maya
// When the GS is loaded, 10 minutes after the event opened.
// Then you can enter using CoreGate.
// We need the MoonStone Ring in the ring slot and wings.
//=========================================================================
//[State] [Condition] [Value]
1
	0	0	0	// None
	1	1	200	// Time in seconds to start the Battle
	2	1	60	// Time in seconds of the message to enter the Tower of Refinement
	3	0	0	// End
end

//=========================================================================
// Battle of Maya Timer
// Here is the time of the battle of Maya. There are three stages of the battle.
// 900 seconds corresponds to 15 minutes and 1,200 within 20 minutes
//=========================================================================
//[State] [Condition] [Value]
2
	0	1	900	// First Battle Scene
	1	1	900	// Second Battle Scene
	2	1	1200	// Third Battle Scene
end

//=========================================================================
// Battle of Maya Cycle¸
//=========================================================================
//[State] [Condition] [Value]
3
	0	0	0	// None

	// First Cycle
	1	1	60	// Stand By
	2	1	15	// Notify
	3	0	0	// Start
	4	0	0	// Maya
	5	1	5	// End Maya
	6	1	3	// End Cycle

	// Second Cycle
	7	1	60	// Stand By
	8	0	0	// Start
	9	0	0	// Maya
	10	1	5	// End Maya
	11	1	3	// End Cycle

	// Third Cycle
	12	1	60	// Stand By
	13	0	0	// Start
	14	0	0	// Maya
	15	1	5	// End Maya
	16	1	10	// End Cycle

	17	1	3	// End
	18	0	0	// End Cycle
end

//============================================================
//                         AI Change
//============================================================
4
	3
	60
	60
	900
end

//============================================================
//                      AI Group Number
//============================================================
5
	20		// Maya Left Hand
	21		// Maya Right Hand
	22		// Maya Hands
end

//============================================================
//           Ice Rate 1/10000 (Ice Storm Maya Skill)
//============================================================
6
	60
end

//=========================================================================
// (Nightmare cycle)¸
//=========================================================================
//[State] [Condition] [Value]
7
	0	0	0	// None
	1	1	5	// Idle
	2	1	10	// Notify
	3	1	1200	// Start
	4	1	5	// End
	5	0	0	// End Cycle
end


//============================================================
//                      AI Group Number
//============================================================-
8
	23
end


//============================
//   [State]  [Cond]  [Value]
//============================
9
	0	0	0	// None
	1	1	82500	// Revitalization
	2	1	300	// Notify
	3	1	2220	// Close
	4	1	180	// Notify
	5	1	5	// End
end


//============================================================
//                Battle Unit Position Check
//============================================================
// [CheckValue]
10
	1		// 0=no, 1=yes
end
 
Play4Free™
Joined
Aug 8, 2007
Messages
469
Reaction score
277
finally i make accout and start server. So i test everythink what you post =)
 
Back
Top