Jump to content

Recommended Posts

Hello community of pkoDev, some time ago we got our hands on the source code for the game we love and have been creating unique stuff for years. Many (including myself) are completely useless when trying to build and make a functional application out of the Chinese sources so not many people were using them. Now, thanks to the Sheep Squad (KONG, Billy, Wrexor, Mii, Foxseiz & Snre3n), they have released the source code for the server-side applications and a client to go along with it. We have to thank them for it, since this improves the community as a whole and now you start seeing a few servers popping up.

 

While they're functional, there have been comments about them having some minor issues, which we as a community can come together to fix as a public source code. This thread is created thanks to KONG for giving the idea and is not to bring any other issue/dramas that showed up in the other thread.

 

This thread's only purpose is to identify issues/improvements and share the code that can fix and/or improve the code, therefore:

  • Anyone is allowed to post anything they might have found, even if they don't have an immediate fix for it. 
  • Anyone is allowed to contribute fixes to other people's issues and their own.
  • Anyone is allowed to contribute improvements to existing code.
  • If any issue fix and/or improvement is shared and you can make the code better, feel free to contribute!

 

Note1: This thread is not about fixing the directories, missing files or compiling source code itself, that's explained on the original release thread.

Note2: This is my first time doing a thread like this, so if I'm missing anything to add, let me know!

 

So for as posting something, lets follow the example stated by KONG.

 

For Bug Reports, follow this:

Bug Title:
Bug Description:
How to replicate:
Status (pending / close / open):
Author (whoever that fixes it):

For Architecture Improvements, follow:

Title: Refactor to MVC design pattern
Reason: scalability and maintainability
Approach:

For Game Improvements, follow this:

Title: 
Reason: Improve existing guild functions
Approach: SQL table, Open-closed, etc
Concerns: concurrency, race, etc

 

Please try posting the actual fixes, if you can, try explaining what was done so the rest of people reading the thread can learn if they're interested. Avoid just posting the whole file like "here's the fixes inside my functions.lua" and posting your 20K line file, try posting just the fixes/changes.

  • Like 2

Share this post


Link to post
Share on other sites

Clean list of the bug reports so you can directly go to the comment that you're interested in.

 

Bug Reports and Status

 

Edited by Angelix
  • Like 2

Share this post


Link to post
Share on other sites

Clean list of the architecture improvements so you can directly go to the comment that you're interested in.

 

Architecture Improvements:

  •  
Edited by Angelix

Share this post


Link to post
Share on other sites
Bug Title: Guild Attribute Refresh
Bug Description: Player attributes are not refreshing instantly when applying an attribute from guild.
How to replicate: Open character and guild stats, buy an attribute from guild and the character attribute will not refresh instantly. Only upon teleporting will they refresh.
Status: Closed
Author: Angelix

 

Source Code - GameApp.h

Description: I think DealAllInGuild function was not calling the function RefreshCha correctly, it was trying to send an extra parameter. Checking whether the extra parameter exists or not does the trick and then sending the called function after.

inline bool CGameApp::DealAllInGuild(int guildID, const char* luaFunc, const char* luaParam){
	BEGINGETGATE();
	CPlayer	*pCPlayer;
	CCharacter	*pCha = 0;
	GateServer	*pGateServer;
	while (pGateServer = GETNEXTGATE()){
		if (!BEGINGETPLAYER(pGateServer))
			continue;
		int nCount = 0;
		while (pCPlayer = (CPlayer *)GETNEXTPLAYER(pGateServer))
		{
			if (++nCount > GETPLAYERCOUNT(pGateServer)){
				LG("player chain list error", "player number:%u, %s\n", GETPLAYERCOUNT(pGateServer), "DealAllInGuild");
				break;
			}
			pCha = pCPlayer->GetCtrlCha();

			if (!pCha)
				continue;
			if (pCha->GetPlayer()->GetMainCha()->GetValidGuildID() == guildID){
				if (luaParam != ""){
					g_CParser.DoString(luaFunc, enumSCRIPT_RETURN_NONE, 0, enumSCRIPT_PARAM_LIGHTUSERDATA, 1, pCha, enumSCRIPT_PARAM_STRING, 1, luaParam, DOSTRING_PARAM_END);
				}
				else{
					g_CParser.DoString(luaFunc, enumSCRIPT_RETURN_NONE, 0, enumSCRIPT_PARAM_LIGHTUSERDATA, 1, pCha, DOSTRING_PARAM_END);
				}
			}
		}
	}
	return true;
}

Lua Functions:

This function was just missing the guildID call at the beginning.

function UpdateGuildAttrs(role)
	local guildID = GetChaGuildID(role)
	if not guildAttributes[guildID] then
		InitGuildAttr(guildID,0,0,0,0,0,0,0,0,0,0,0,0)
	end
	local pkt = GetPacket()
	WriteCmd(pkt,508)
	WriteDword(pkt,GetRoleID(role))
	WriteDword(pkt,0)
	WriteByte(pkt,32)
	WriteDword(pkt,guildAttributes[guildID][ATTR_PDEF]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_MSPD]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_ASPD]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_MXATK]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_DEF]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_HIT]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_FLEE]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_HREC]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_SREC]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_MXHP]  or 0)
	WriteDword(pkt,guildAttributes[guildID][ATTR_MXSP]  or 0)
	SendPacket(role,pkt)
end

 

  • Like 1

Share this post


Link to post
Share on other sites
Bug Title: amplifier unlimited stats 
Bug Description:  remove amps stats after switch  or use a ticket in same region , unlimited stats time if player login after real ticks finished 
example : used nana for 10 min , if player logged out then logged after 11min or more nana will be 15999998 seconds
Status: Closed
Author: mkhzaleh

this will  save real time and stop ticks when player logout 
inside Character.cpp

search for 
 

void CCharacter::SwitchMap(SubMap *pCSrcMap, cChar *szTarMapName, Long lTarX, Long lTarY, bool bNeedOutSrcMap, Char chSwitchType, Long lTMapCpyNO)

replace with 
 

void CCharacter::SwitchMap(SubMap *pCSrcMap, cChar *szTarMapName, Long lTarX, Long lTarY, bool bNeedOutSrcMap, Char chSwitchType, Long lTMapCpyNO)
{T_B
	if (!pCSrcMap)
		return;

	BreakAction();
	
	if( IsPlayerCha() ) 
	{
		SetSubMap( pCSrcMap );
		GetPlayer()->MisGooutMap();
		SetSubMap( NULL );
	}

	if (bNeedOutSrcMap && pCSrcMap)
		pCSrcMap->GoOut(this);

	if (!strcmp(pCSrcMap->GetName(), szTarMapName)) // 同地图间切换
	{
		if (GetPlayer())
			//LG("enter_map", "SwitchMap(同地图切换,控制角色名 %s[主角色名 %s],地图名 %s)--------\n", GetLogName(), GetPlyMainCha()->GetLogName(), szTarMapName);
			LG("enter_map", "SwitchMap(the same map switch,control player name %s[mainplayer %s],mapname %s)--------\n", GetLogName(), GetPlyMainCha()->GetLogName(), szTarMapName);
		if (m_SMoveRedu.ulStartTick == 0xffffffff)
			m_SMoveRedu.ulStartTick = GetTickCount();
		if(!IsPlayerCha()) // 非玩家角色,则在自己的出生点重生
		{
			m_SFightInit.chTarType = 0;
			m_CChaAttr.Init(GetCat());
			Square	SSrcShape = GetShape();
			Square	STarShape = {{lTarX, lTarY}, GetRadius()};
			if (!pCSrcMap->Enter(&STarShape, this))
				pCSrcMap->Enter(&SSrcShape, this);
		}
		else
		{
			SStateData2String(this, g_skillstate, 1024);
			//PStateData2String(this, g_skillstate, 1024);
			if (IsBoat())
				g_strChaState[1] = g_skillstate;
			else
				g_strChaState[0] = g_skillstate;
			Square SSrcShape = GetShape();
			Square STarShape = {{lTarX, lTarY}, SSrcShape.radius};
			if (!pCSrcMap->EnsurePos(&STarShape, this)) // 进入失败
			{
				lTarX = SSrcShape.centre.x;
				lTarY = SSrcShape.centre.y;
			}

			GetPlayer()->GetMainCha()->Cmd_EnterMap(szTarMapName, lTMapCpyNO, lTarX, lTarY);

			// 角色护送NPC同步地图切换			
			GetPlayer()->MisEnterMap();
		}

		SetExistState(enumEXISTS_WAITING);
		return;
	}
	else
	{
		bool bVolunteer = false;
		SubMap	*pCBackM = GetSubMap();
		SetSubMap(pCSrcMap);
		pCSrcMap->BeforePlyOutMap(this);
		//LG("enter_map", "SwitchMap(不同Server地图切换,控制角色名 %s[主角色名 %s],原地图 %s,目标地图 %s)--------\n", GetLogName(), GetPlyMainCha()->GetLogName(), pCSrcMap->GetName(), szTarMapName);
		LG("enter_map", "SwitchMap(differ Server map switch,control player name %s[mainplayer %s],formerly map %s,aimmap %s)--------\n", GetLogName(), GetPlyMainCha()->GetLogName(), pCSrcMap->GetName(), szTarMapName);
		if (GetSubMap())
			//LG("enter_map", "角色地图名 %s\n", GetSubMap()->GetName());
			LG("enter_map", "character map name %s\n", GetSubMap()->GetName());
		// 资料写数据库
		CPlayer	*pPlayer = GetPlayer();
		if(!pPlayer)
			return;

		//组队面板修改
		if(GetPlyMainCha()->IsVolunteer())
		{
			bVolunteer = true;
			GetPlyMainCha()->Cmd_DelVolunteer();
		}

		game_db.SavePlayer(pPlayer, enumSAVE_TYPE_SWITCH);
		//LG("enter_map", "保存数据成功\n");
		LG("enter_map", "save data succeed\n");

		// 角色护送NPC同步地图切换
		pPlayer->MisLogout();

		SetSubMap(pCBackM);

		// 发送协议
		WPACKET	l_wpk	=GETWPACKET();
		WRITE_CMD(l_wpk, CMD_MT_SWITCHMAP);
		WRITE_STRING(l_wpk, pCSrcMap->GetName());
		WRITE_LONG(l_wpk, pCSrcMap->GetCopyNO());
		WRITE_LONG(l_wpk, GetShape().centre.x);
		WRITE_LONG(l_wpk, GetShape().centre.y);
		WRITE_STRING(l_wpk, szTarMapName);
		WRITE_LONG(l_wpk, lTMapCpyNO);
		WRITE_LONG(l_wpk, lTarX);
		WRITE_LONG(l_wpk, lTarY);
		if (chSwitchType == enumSWITCHMAP_DIE) // 死亡导致的地图切换(如果目标地图不可达,则gate强制玩家下线,不会返回源地图)
			WRITE_CHAR(l_wpk, 1);
		else
			WRITE_CHAR(l_wpk, 0);
		ReflectINFof(this,l_wpk);

        g_pGameApp->DelPlayerIdx(pPlayer->GetDBChaId());
        g_pGameApp->m_dwPlayerCnt--;

		pPlayer->Free();
		// 删除gate server对应的维护信息
		pPlayer->OnLogoff();
        DELPLAYER(pPlayer);
		//LG("enter_map", "结束进入地图\n\n");
		LG("enter_map", "finish enter map\n\n");
	}
T_E}

 inside GameDB.cpp
search for

 

PStateData2String(pCha, g_skillstate, defSSTATE_DATE_STRING_LIN);
replace with
SStateData2String(pCha, g_skillstate, defSSTATE_DATE_STRING_LIN);

 

  • Like 3

Share this post


Link to post
Share on other sites

Bug Title: Random Disconnects
Bug Description: When many few players online it randomly disconnects.. any of them with the reason 10054 which says that "Host forcibly closed your connection"
How to replicate:
The only way to replicate is to login and wait for the game to disconnect you.. so you can see the reason.
Status (pending / close / open): OPEN (Not Fixed)
Author (whoever that fixes it):

Edited by Zett

Share this post


Link to post
Share on other sites
10 hours ago, Daisuke said:

Bug Title: "Buy Page"

Bug Description: Items do not display Level via "Buy Page"

How to replicate: Items do not display Level via "Buy Page"

Status: (OPEN (Not Fixed))

Author: whoever that fixes it

https://gyazo.com/66e515fb68c8c5779b2e6c7e493970dd

I think that might be on client side, couldn't find something related to that like set view or something from server sources. I could probably be something related like this thread.

Update: Fixed by applying this patch to client.

Edited by Angelix
  • Like 1

Share this post


Link to post
Share on other sites
Bug Title: "Nightmare Demonic Helm"

Bug Description: Nightmare Demonic Helm upgrade missing

Status: (Closed)

Author: mkhzaleh

///

Bug Title: "Admiral Cloak Upgrade"

Bug Description: Admiral Cloak Upgrade missing

Status: (Closed)

Author: mkhzaleh

    Cloak 

    Helm

  • Like 2

Share this post


Link to post
Share on other sites
Bug Title: "Swing invisible "

Bug Description: Swing missing effect/models/texture

Status: (Closed)

Author: mkhzaleh & @GOAT

Swings

Edited by mkhzaleh
  • Like 2

Share this post


Link to post
Share on other sites
On 8/14/2019 at 5:07 AM, Angelix said:

Please try posting the actual fixes, if you can, try explaining what was done so the rest of people reading the thread can learn if they're interested. Avoid just posting the whole file like "here's the fixes inside my functions.lua" and posting your 20K line file, try posting just the fixes/changes.

 

8 hours ago, Angelix said:

I think that might be on client side, couldn't find something related to that like set view or something from server sources. I could probably be something related like this thread.

Update: Fixed by applying this patch to client.

Could you note what's done? thanks.

Tho theres another thing missing with Items:

Bug Title: Item Price on Invertory
Bug Description: Item Value's (Price) on Invertory is not divided by 2
How to replicate: Buy 1 Item at NPC for ex: 5,000 Gold, hover ur mouse on invertory it will still show 5,000 Gold but if you drag to Sell it gives 2,500 Gold, the bug is that it should show 2,500 while you hover ur mouse on invertory aswell. 
Status: OPEN (Not Fixed)

Share this post


Link to post
Share on other sites
5 hours ago, xiaoyuyu321 said:

image.png.fd706d8b9775a603380dd3491ca4e8b9.pngimage.png.cf4da052d2b11a3f0d22d4c409d8a6eb.png

 

Click purchase successfully, check the backpack did not purchase items?

Crystal does not decrease immediately, IGS must be reactivated

 

 

_igs					= {}												-- 
_igs.SavePath			= GetResPath('../Log/Igs.log')		--

_igs.Initial			= function(File)
	Table				= io.open(File, 'r')
	if Table ~= nil then
		io.close(Table)
	else
		table.save({}, File, 'w')
	end
end
_igs.Initial(_igs.SavePath)	

add this to IGS.lua

edit 
function IGSLog(msg)
    local file = "Log/Igs.log"


or just create new folder and rename it to GSlog  and create new file inside it "Igs.log"

Edited by mkhzaleh
  • Like 1

Share this post


Link to post
Share on other sites

Npc Dialogue

 

Base: Normal default color - Dark Blue

 

Use: It can be helpful for players when reading options before clicking.

 

Open Game.exe with any Hex-editor

Look for 0xFF0000AF

Address: image.png.457c88bde8d3cfe95b0dfc3ec27ec295.png

Replace: Value with any R,G,B value you wish. -> Must convert and reverse order

 

Final Result: Change hover color to other color

1yQxKf9.gif.aa006ba427e381d4543c747fabc0a04a.gif

 

 

Edited by GOAT
  • Like 3

Share this post


Link to post
Share on other sites
13 hours ago, Zett said:

Could you note what's done? thanks.

Sorry. I could not provide what was fully done since it was given to me by a friend that hexed it. It fixes the issue of "Level Requirement" not showing up on NPC's "BuyPage".

Share this post


Link to post
Share on other sites
9 hours ago, mkhzaleh said:

 														
  
	  
	 
	
	

将此添加到IGS.lua

编辑 
函数IGSLog(msg)
    local file =“Log / Igs.log”


或者只是创建新文件夹并将其重命名为GSlog并在其中创建新文件“Igs.log”

Thanks!

Share this post


Link to post
Share on other sites
Quote

whenever I left it full screen or 1024 x .. the screen turns blue

 

@Daisuke just add CameraConf1024.clu file  in  scripts/lua client, you can get that from top2/pko2 clients

Edited by squaller
  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Daisuke said:

does anyone have any idea how this CO VIP Chat works? How do I allow a player to talk in this chat?

Incomplete feature. I think Billy wanted to do some VIP level function where
each VIP level unlocks new features to the game (from a marketing perspective).

  • Like 1

Share this post


Link to post
Share on other sites
Bug Title: GetRoleByID Function 
Bug Description: The lua function "GetRoleByID" is not properly returning the role.
How to replicate: Insert a character ID into "GetRoleByID" function and it won't return the role.
Status: Closed
Author: Angelix

GameServer Source / CharScript.cpp

inline int lua_GetRoleByID(lua_State* L)
{
	BOOL bValid = lua_gettop(L) == 1 && lua_isnumber(L, 1);
	if (!bValid)
	{
		E_LUAPARAM;
		return 0;
	}
	DWORD dwChaDBID = (DWORD)lua_tonumber(L, 1);
	CPlayer* pPlayer = g_pGameApp->GetPlayerByDBID(dwChaDBID);
	if (pPlayer)
	{
		CCharacter* pCha = (CCharacter*)pPlayer->GetMainCha();
		lua_pushlightuserdata(L, (CCharacter*)pCha);
		return 1;
	}
	//lua_pushlightuserdata(L, NULL);
	return 0;
}

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×