Snre3n 94 Report post Posted April 21, 2019 (edited) A growing collection of features/concepts developed and implemented in source code.Got any ideas? Let me know, it might end up here. Edited August 21, 2019 by Snre3n 7 Quote Share this post Link to post Share on other sites
Snre3n 94 Report post Posted August 4, 2019 (edited) //... static char buf[6]; const float seconds_remaining = _fPlayTime - _fCurTime; const int minutes = static_cast<int>(seconds_remaining / 60); const int seconds = static_cast<int>(seconds_remaining - (minutes * 60)); minutes > 1 ? _snprintf_s(buf, _TRUNCATE, "%.2d:%.2d", minutes, seconds) : seconds > 1 ? _snprintf_s(buf, _TRUNCATE, "%d", seconds) : _snprintf_s(buf, _TRUNCATE, "%.1f", seconds_remaining); CGuiFont::s_Font.BRender(0, buf, x, y, COLOR_RED, COLOR_BLACK); } // End of function void CAniClock::Render(int x, int y); Edited October 15, 2019 by Snre3n C++ version compatibility ( remove use of auto specifer ) 5 4 Quote Share this post Link to post Share on other sites
Snre3n 94 Report post Posted August 4, 2019 // Function: void CHeadSay::Render( D3DXVECTOR3& pos ); // Use this as a reference where to insert the code, its already in source. s_dwNamePartsColors[NAME_INDEX][0] = _dwNameColor; // const stNetChangeChaPart part = _pOwn->GetPart(); const int id = part.SLink[enumEQUIP_NECK].sID; switch (id) { case 6611: { // GM's Necklace in iteminfo s_dwNamePartsColors[NAME_INDEX][0] = COLOR_RED; } break; } 1 Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted August 4, 2019 Dude portal opening time send server time once to client (so client and server can have steady beat), initial date and time of portal (only once). Calculate opening duration at client side so serverside CPU isnt in use.face reconstruction same as hair, but requires different voucher to change the face Yknow, I've always had massive visions to the future of this game but no longer dev But maybe I can contribute here too. Quote Share this post Link to post Share on other sites
Angelix 374 Report post Posted August 5, 2019 (edited) Little contribution. This should allow you to choose were a player revives when they press the prompt "revive in town". For those interested in making new map scripts and also stuff like respawning near a portal if a map is still active like "Chaos Argent" and such. Lua function and its corresponding source adjustment. MapRespawnOnDeath = function(Player) return "" end void CCharacter::BackToCity(bool bDie, cChar *szCityName, Long lMapCpyNO, Char chSwitchType) { SubMap *pCMap = GetSubMap(); pCMap->GoOut(this); SetToMainCha(bDie); CCharacter *pCMainCha = GetPlyMainCha(); pCMainCha->SetExistState(enumEXISTS_NATALITY); //pCMainCha->m_timerScripts.Reset(); /* if(bDie && (!strcmp(pCMap->GetName(), "guildwar"))) { if(GetGuildType() == emGldTypePirate) { szCityName = "guildwarpirateside"; } else { szCityName = "guildwarnavyside"; } } else if(bDie && (!strcmp(pCMap->GetName(), "guildwar2"))) { if(GetGuildType() == emGldTypePirate) { szCityName = "guildwarpirateside2"; } else { szCityName = "guildwarnavyside2"; } } */ if (g_CParser.DoString("MapRespawnOnDeath", enumSCRIPT_RETURN_STRING, 1, enumSCRIPT_PARAM_LIGHTUSERDATA, 1, pCMainCha, DOSTRING_PARAM_END)) szCityName = g_CParser.GetReturnString(0); if (!szCityName || !strcmp(szCityName, "")) pCMainCha->ResetBirthInfo(); else { SBirthPoint *pSBirthP; pSBirthP = GetRandBirthPoint(GetLogName(), szCityName); SetBirthMap(pSBirthP->szMapName); SetPos(pSBirthP->x * 100, pSBirthP->y * 100); } pCMainCha->SwitchMap(pCMap, pCMainCha->GetBirthMap(), pCMainCha->GetPos().x, pCMainCha->GetPos().y, false, chSwitchType, lMapCpyNO); } Edited August 5, 2019 by Angelix 2 Quote Share this post Link to post Share on other sites
Snre3n 94 Report post Posted August 21, 2019 (edited) @KONG Quote portal opening time send server time once to client (so client and server can have steady beat), initial date and time of portal (only once). Calculate opening duration at client side so serverside CPU isnt in use. Code provided is proof of concept only. Implementation: Spoiler scripts\lua\default\skin\default_new/main.lua ----------------------------------------------------------------------- -- View Portal Openings/Closings ----------------------------------------------------------------------- frmPortalTime = UI_CreateForm("frmPortalTime", FALSE, 0, 0, 350, 200, TRUE, TRUE) UI_ShowForm( frmPortalTime, FALSE ) UI_FormSetHotKey( frmPortalTime, ALT_KEY, HOTKEY_T ) UI_AddFormToTemplete( frmPortalTime, FORM_MAIN ) list = UI_CreateListView( frmPortalTime, "list", 296, 200, 0, 0, 3, 1) UI_LoadListItemImage(list, "texture/ui/NBotton.tga", 1, 1, 100, 171, 296, 21 ) UI_SetListFontColor( list, COLOR_RED, COLOR_RED ) UI_SetListIsMouseFollow( list, TRUE) UI_SetListRowHeight( list, 25 ) id = UI_GetScroll( list ) UI_SetIsEnabled( id, TRUE ) UI_ListViewSetTitle( list, 0, 100, "", 0, 0, 0, 0 ) UI_ListViewSetTitle( list, 1, 100, "", 0, 0, 0, 0 ) UI_ListViewSetTitle( list, 2, 100, "", 0, 0, 0, 0 ) source/inc/Common/NetCommand.h MESSAGE_DEF(CMD_MC_PORTALTIMES, CMD_MC_BASE + 109, Portal time opening / closing) MESSAGE_DEF(CMD_TM_PORTALTIMES, CMD_TM_BASE + 11, Portal time opening/closing) source/inc/Game_v2.0/UIGlobalVar.h class CPortalTime; extern CPortalTime g_stUIPortalTime; source/src/Game_v2.0/UIGlobalVar.cpp #include "UIPortalTime.h" CPortalTime g_stUIPortalTime; source/inc/Game_v2.0/UIPortalTime.h #pragma once #include "UIGlobalVar.h" // Data only class Portal { public: Portal(std::string destination, time_t entryFirst, time_t entryInterval, time_t entryClose, time_t destinationClose); std::string_view Destination() const { return destination; } //private: std::string destination; time_t entryFirst{0}; time_t entryInterval{0}; time_t entryClose{0}; //NOTE: This may be useless data... time_t destinationClose{0}; }; // Interface for UI only namespace GUI { class CPortalTime : CUIInterface { public: virtual bool Init() override; void Add(Portal portal); private: std::vector<Portal> portals; CForm* frm{nullptr}; CListView* list{nullptr}; protected: virtual void FrameMove(DWORD dwTime) override; }; } // namespace GUI source/src/Game_v2.0/UIPortalTime.cpp #include "stdafx.h" #include "UIPortalTime.h" #include "UIFormMgr.h" #include "UIListView.h" #include <ctime> Portal::Portal(std::string destination, time_t entryFirst, time_t entryInterval, time_t entryClose, time_t destinationClose) : destination(destination), entryFirst(entryFirst), entryInterval(entryInterval), entryClose(entryClose), destinationClose(destinationClose) { } bool GUI::CPortalTime::Init() { if (frm = CFormMgr::s_Mgr.Find("frmPortalTime"); !frm) { return false; } frm->SetIsDrag(true); if (list = dynamic_cast<CListView*>(frm->Find("list")); !list) { return false; } list->GetList()->GetItemImage()->SetColor(COLOR_BLUE); list->GetList()->GetItems()->SetItemMargin(20, 0); list->SetMargin(0, 0, 0, 0); return true; } void GUI::CPortalTime::Add(Portal entrance) { portals.emplace_back(entrance); auto row = list->AddItemRow(); // Column 1 - Destination auto pItem = new CItem; pItem->SetString(entrance.Destination().data()); row->SetIndex(0, pItem); // Column 2 - Portal state pItem = new CItem; pItem->SetString("Status"); row->SetIndex(1, pItem); // Column 3 - Time pItem = new CItem; pItem->SetString("Time"); row->SetIndex(2, pItem); list->Refresh(); } void GUI::CPortalTime::FrameMove(DWORD dwTime) { if (!frm->GetIsShow()) { return; } // Update entrance times static tm _tm{}; const auto timeNow = time(nullptr); for (auto row = 0; row < portals.size(); ++row) { const auto& portal = portals[row]; auto timeDiff = timeNow - portal.entryFirst; static const char* state_opening = "Opening"; static const char* state_closing = "Closing"; static const char* state_unknwon = "Unknown"; auto state = [&]() -> const char* { if (portal.entryInterval) { auto time_open = timeDiff % portal.entryInterval; return time_open > portal.entryClose ? state_opening : state_closing; } return state_unknwon; }(); auto time_countdown = [&]() -> time_t { if (state == state_opening) { return (timeDiff % portal.entryInterval); } if (state == state_closing) { return portal.entryClose - (timeDiff % portal.entryInterval); } return 0; }(); //Update state auto pItem = list->GetItemObj(row, 1); pItem->SetString(state); //Update time countdown std::tm* p = gmtime(&time_countdown); static char buf[80]; strftime(buf, sizeof(buf), "%T", p); pItem = list->GetItemObj(row, 2); pItem->SetString(buf); } } source/src/GameServer/GameAppNet.cpp // CGameApp::ProcessPacket(GateServer* pGate, RPACKET pkt) case CMD_TM_PORTALTIMES: { if (m_mapnum <= 0) { break; } const auto gatePlayer = READ_LONG(pkt); auto wpk = GETWPACKET(); WRITE_CMD(wpk, CMD_MC_PORTALTIMES); unsigned short maps_with_portal = 0; for (auto i = 0; i < m_mapnum; ++i) { if (auto& map = m_MapList[i]; map) { if (strcmp(map->m_szEntryMapName, "") == 0) { continue; } if (map->m_SEntryPos.x == 0 && map->m_SEntryPos.y == 0) { continue; } if (time(nullptr) < map->m_tEntryFirstTm) { continue; } WRITE_CHAR(wpk, map->GetMapID()); WRITE_LONGLONG(wpk, map->m_tEntryFirstTm); WRITE_LONGLONG(wpk, map->m_tEntryTmDis); WRITE_LONGLONG(wpk, map->m_tEntryOutTmDis); WRITE_LONGLONG(wpk, map->m_tMapClsTmDis); ++maps_with_portal; } } WRITE_SHORT(wpk, maps_with_portal); WRITE_LONG(wpk, gatePlayer); pGate->SendData(wpk); } break; source/src/Game_v2.0/NetIF.cpp #include "UIPortalTime.h" // NetIF::HandlePacketMessage(DataSocket* datasock, LPRPACKET pk) case CMD_MC_PORTALTIMES: { for (auto portalCount = pk.ReverseReadShort(); portalCount > 0; --portalCount) { static char buf[500]; const auto mapID = pk.ReadChar(); const time_t EntryFirstTm = pk.ReadLongLong(); const time_t tEntryTmDis = pk.ReadLongLong(); const time_t tEntryOutTmDis = pk.ReadLongLong(); const time_t tMapClsTmDis = pk.ReadLongLong(); std::string s = GetMapInfo(mapID)->szName; g_stUIPortalTime.Add({static_cast<CMapInfo*>(GetMapInfo(mapID))->szName, EntryFirstTm, tEntryTmDis, tEntryOutTmDis, tMapClsTmDis}); } } break; source/src/GateServer/ToClient.cpp // ToClient::CM_BGNPLAY(DataSocket* datasock, RPacket& recvbuf) { auto wpk = g_GateServer->toGameServer->GetWPacket(); wpk.WriteCmd(CMD_TM_PORTALTIMES); wpk.WriteLong(MakeULong(player)); g_GateServer->toGameServer->SendAllGameServer(wpk); } source/src/GateServer/ToGameServer.cpp // ToGameServer::OnProcessData(DataSocket* datasock, RPacket& recvbuf) case CMD_MC_PORTALTIMES: { RPacket rpk = recvbuf; if (auto player = static_cast<Player*>(MakePointer(rpk.ReverseReadLong())); player) { rpk.DiscardLast(sizeof(sizeof(uLong))); auto wpk = WPacket(rpk).Duplicate(); g_GateServer->toClient->SendData(player->m_datasock, wpk); } } break; Edited August 21, 2019 by Snre3n 7 1 Quote Share this post Link to post Share on other sites
ahmad 3 Report post Posted August 23, 2019 implemented lua Sql inside gameserver GetPlayerMac GetPlayerIP Quote Share this post Link to post Share on other sites
MonkeyCode 453 Report post Posted August 23, 2019 (edited) 19 hours ago, ahmad said: implemented lua Sql inside gameserver GetPlayerMac GetPlayerIP Honestly, implementing any of these things is a step back in development. LuaSql is also very bad, lua is meant to be the highest level of abstraction yet it is interacting with low level objects like SQL table... introducing more problems than answers. Again, this is an opportunity to introduce new and exciting things to the game, why bother mentioning old things that have already been implemented...Another concept: introducing a lua "userdata" for the data type guild local guild = GetGuildData(<id?>) GuildNotice(guild, "some crazy string to notify that a guildmate have stolen the boss drops") or refactor whole lua system: guild:notice("some crazy string to notify that a guildmate have stolen the boss drops") Edited August 23, 2019 by KONG 1 Quote Share this post Link to post Share on other sites
Daisuke 7 Report post Posted August 31, 2019 (edited) On 8/4/2019 at 9:21 PM, Angelix said: Little contribution. This should allow you to choose were a player revives when they press the prompt "revive in town". For those interested in making new map scripts and also stuff like respawning near a portal if a map is still active like "Chaos Argent" and such. Lua function and its corresponding source adjustment. MapRespawnOnDeath = function(Player) return "" end void CCharacter::BackToCity(bool bDie, cChar *szCityName, Long lMapCpyNO, Char chSwitchType) { SubMap *pCMap = GetSubMap(); pCMap->GoOut(this); SetToMainCha(bDie); CCharacter *pCMainCha = GetPlyMainCha(); pCMainCha->SetExistState(enumEXISTS_NATALITY); //pCMainCha->m_timerScripts.Reset(); /* if(bDie && (!strcmp(pCMap->GetName(), "guildwar"))) { if(GetGuildType() == emGldTypePirate) { szCityName = "guildwarpirateside"; } else { szCityName = "guildwarnavyside"; } } else if(bDie && (!strcmp(pCMap->GetName(), "guildwar2"))) { if(GetGuildType() == emGldTypePirate) { szCityName = "guildwarpirateside2"; } else { szCityName = "guildwarnavyside2"; } } */ if (g_CParser.DoString("MapRespawnOnDeath", enumSCRIPT_RETURN_STRING, 1, enumSCRIPT_PARAM_LIGHTUSERDATA, 1, pCMainCha, DOSTRING_PARAM_END)) szCityName = g_CParser.GetReturnString(0); if (!szCityName || !strcmp(szCityName, "")) pCMainCha->ResetBirthInfo(); else { SBirthPoint *pSBirthP; pSBirthP = GetRandBirthPoint(GetLogName(), szCityName); SetBirthMap(pSBirthP->szMapName); SetPos(pSBirthP->x * 100, pSBirthP->y * 100); } pCMainCha->SwitchMap(pCMap, pCMainCha->GetBirthMap(), pCMainCha->GetPos().x, pCMainCha->GetPos().y, false, chSwitchType, lMapCpyNO); } Ty @Angelix Edited September 1, 2019 by Daisuke 1 Quote Share this post Link to post Share on other sites
Fritt 5 Report post Posted May 26, 2020 @Snre3n Maybe adding something as Fps? That will allow players to switch from 30 Fps to 60 Fps through in-game Game Settings Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted May 27, 2020 (edited) 18 hours ago, Fritt said: @Snre3n Maybe adding something as Fps? That will allow players to switch from 30 Fps to 60 Fps through in-game Game Settings Take a look at the simplified "addSystemOption" function in .clu files made by Sheep Squad. To unlock framerate, take a look at SteadyFrame.cpp. Edit: I mean Sheep Squad as in Corsairs Online client files Edited May 27, 2020 by Mdrst Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites
Fritt 5 Report post Posted May 27, 2020 14 minutes ago, Mdrst said: Take a look at the simplified "addSystemOption" function in .clu files made by Sheep Squad. To unlock framerate, take a look at SteadyFrame.cpp. Edit: I mean Sheep Squad as in Corsairs Online client files Yeah but thats a clean code same as on normal sources, thats why i suggested adding something as Fps Option 30/60 Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted May 27, 2020 Just now, Fritt said: Yeah but thats a clean code same as on normal sources, thats why i suggested adding something as Fps Option 30/60 function addSystemOption(frm,compName,cap,hint,cap1,cap2,y) labGame = UI_CreateCompent( frm, LABELEX_TYPE, "labGame", 30, 10, 12, y ) UI_SetCaption( labGame, cap ) UI_SetTextColor( labGame, COLOR_BLACK ) UI_SetLabelExFont( labGame, DEFAULT_FONT, TRUE, COLOR_WHITE ) UI_SetHint(labGame,hint) labGame = UI_CreateCompent( frm, LABELEX_TYPE, "labGame", 30, 10, 70, y ) UI_SetCaption( labGame, cap1 ) UI_SetTextColor( labGame, COLOR_BLACK ) UI_SetLabelExFont( labGame, DEFAULT_FONT, TRUE, COLOR_WHITE ) chkHelpmodel1 = UI_CreateCompent( frm, CHECK_TYPE, "chkHelpmodel1", 10, 10, 102, y ) UI_LoadImage( chkHelpmodel1, "texture/ui/QQ2.tga", UNCHECKED, 10, 10, 40, 231 ) UI_LoadImage( chkHelpmodel1, "texture/ui/QQ2.tga", CHECKED, 10, 10, 52, 231 ) labGame = UI_CreateCompent( frm, LABELEX_TYPE, "labGame", 30, 10, 115, y ) UI_SetCaption( labGame, cap2 ) UI_SetTextColor( labGame, COLOR_BLACK ) UI_SetLabelExFont( labGame, DEFAULT_FONT, TRUE, COLOR_WHITE ) chkHelpmodel2 = UI_CreateCompent( frm, CHECK_TYPE, "chkHelpmodel2", 10, 10, 147, y ) UI_LoadImage( chkHelpmodel2, "texture/ui/QQ2.tga", UNCHECKED, 10, 10, 40, 231 ) UI_LoadImage( chkHelpmodel2, "texture/ui/QQ2.tga", CHECKED, 10, 10, 52, 231 ) cbxEffmodel = UI_CreateCompent( frm, CHECK_GROUP_TYPE, compName, 0, 0, 0, 0 ) UI_AddGroupBox( cbxEffmodel, chkHelpmodel1 ) UI_AddGroupBox( cbxEffmodel, chkHelpmodel2 ) end You can just import the code above into a clean system.clu. Regardless, you should take a look at how system options are added/stored in Corsairs Client Source to make your own option for framerate. Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites
Fritt 5 Report post Posted May 27, 2020 (edited) @Mdrst But you can't just import or add an option without having a working code, and the current Fps clean code is not made to be used as a Game Option that you can switch between 30/60, i already know where to add the option on client but i asked for the concept Edited May 27, 2020 by Fritt Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted May 27, 2020 Just now, Fritt said: @Mdrst But you can't just import or add an option without having a working code, and the current Fps clean code is not made to be used as a Game Option that you can switch between 30/60, i already know where to add the option on client but i asked for the concept Why not? Just make a variable instead of a hardcoded value in SteadyFrame and update it accordingly. Add the variable to header files and call it whenever user changes the framerate. I can't see why you wouldn't be able to do that, am I missing something? Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites
Fritt 5 Report post Posted May 27, 2020 @Mdrst If i'd know i would post it here instead of making a suggestion to him, as he asked for ideas. Quote Share this post Link to post Share on other sites
Mdrst 38 Report post Posted May 27, 2020 2 minutes ago, Fritt said: @Mdrst If i'd know i would post it here instead of making a suggestion to him, as he asked for ideas. Ah, sorry, I misinterpreted you then. Once I have the time I'll try adding it myself and posting here. Quote "Beware of bugs in the above code; I have only proved it correct, not tried it." - Donald E. Knuth Share this post Link to post Share on other sites
Fritt 5 Report post Posted June 3, 2020 Also Suggestion: Adding GetPlayerIP/GetPlayerMac at source? Quote Share this post Link to post Share on other sites
IfYouSeeMeRun 7 Report post Posted September 4, 2022 On 8/4/2019 at 10:59 PM, Snre3n said: //... static char buf[6]; const float seconds_remaining = _fPlayTime - _fCurTime; const int minutes = static_cast<int>(seconds_remaining / 60); const int seconds = static_cast<int>(seconds_remaining - (minutes * 60)); minutes > 1 ? _snprintf_s(buf, _TRUNCATE, "%.2d:%.2d", minutes, seconds) : seconds > 1 ? _snprintf_s(buf, _TRUNCATE, "%d", seconds) : _snprintf_s(buf, _TRUNCATE, "%.1f", seconds_remaining); CGuiFont::s_Font.BRender(0, buf, x, y, COLOR_RED, COLOR_BLACK); } // End of function void CAniClock::Render(int x, int y); Awesome , that mod/tweak , well i haven't played TOP in like 5 years but looks cool , i have a good collection of tweaks will see if i find them when i get some time and post them , like camtweak,noskill animation,some good amount of glows tweaks,inv tweak have 2-3(no scroll etc) , hmm monster tweaks( some monster don't show ) and same with items i made all of those except the inv tweak coz a friend passed me , Btw was wondering... do i need that "source code/mod loader" to use this tweak? isn't it just a exe may .lua/.dll file standalone? Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted September 4, 2022 5 hours ago, IfYouSeeMeRun said: Awesome , that mod/tweak , well i haven't played TOP in like 5 years but looks cool , i have a good collection of tweaks will see if i find them when i get some time and post them , like camtweak,noskill animation,some good amount of glows tweaks,inv tweak have 2-3(no scroll etc) , hmm monster tweaks( some monster don't show ) and same with items i made all of those except the inv tweak coz a friend passed me , Btw was wondering... do i need that "source code/mod loader" to use this tweak? isn't it just a exe may .lua/.dll file standalone? Hello @IfYouSeeMeRun, This piece of code is for server developers who want add that feature into their game client, this is not a tweak in its natural sense. 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
IfYouSeeMeRun 7 Report post Posted September 4, 2022 59 minutes ago, V3ct0r said: Hello @IfYouSeeMeRun, This piece of code is for server developers who want add that feature into their game client, this is not a tweak in its natural sense. Ohh i had no idea , do u think u can make a tweak for skills CD like that one? would be awsome ( tho no big deal anyway coz i dont know when i will play agn or if i will but incase .. ) Quote Share this post Link to post Share on other sites