• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ fit code

Jpstafe

Well-Known Member
Joined
Aug 8, 2011
Messages
507
Reaction score
68
Have updated my server to the latest tfs commits, now i want to add ping for otcv8 but it giving me error, i think i need to adapt part of the code
Lua:
void ProtocolGame::parseNewPing(NetworkMessage& msg)
{
    uint32_t pingId = msg.get<uint32_t>();
    uint16_t localPing = msg.get<uint16_t>();
    uint16_t fps = msg.get<uint16_t>();

    
    addGameTask(&Game::playerReceiveNewPing, player->getID(), localPing, fps);
    g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::sendNewPing, getThis(), pingId)));
}
can somebody help me?
Code:
quests.cpp
1>C:\Users\jpstafe\Documents\GitHub\pro-ot\src\protocolgame.cpp(2423,74): error C2672: 'ProtocolGame::addGameTask': no matching overloaded function found
1>C:\Users\jpstafe\Documents\GitHub\pro-ot\src\protocolgame.h(338,8): message : could be 'void ProtocolGame::addGameTask(Callable &&)' (compiling source file ..\src\protocolgame.cpp)
1>C:\Users\jpstafe\Documents\GitHub\pro-ot\src\protocolgame.cpp(2423,2): message : 'void ProtocolGame::addGameTask(Callable &&)': expects 1 arguments - 4 provided
1>C:\Users\jpstafe\Documents\GitHub\pro-ot\src\protocolgame.h(338): message : see declaration of 'ProtocolGame::addGameTask'
1>raids.cpp
1>rsa.cpp
1>scheduler.cpp
 
Latest tfs-master uses lambdas instead but your code calls already removed helpers:

C++:
        // Helpers so we don't need to bind every time
        template <typename Callable, typename... Args>
        void addGameTask(Callable&& function, Args&&... args) {
            g_dispatcher.addTask(createTask(std::bind(std::forward<Callable>(function), &g_game, std::forward<Args>(args)...)));
        }

        template <typename Callable, typename... Args>
        void addGameTaskTimed(uint32_t delay, Callable&& function, Args&&... args) {
            g_dispatcher.addTask(createTask(delay, std::bind(std::forward<Callable>(function), &g_game, std::forward<Args>(args)...)));
        }

These are 2 main changes you should see:
1. Allow to pass lambdas into addGameTask

2. Replace addGameTask with g_dispatcher.addTask(TaskFunc&& f)
 
Last edited:
yeah solved it. but end up dropping it all because outfits mounts and change colors where not working properly in this updated server :/
 
Up i have fixed things but im already trying to convert old code to the new one. also added both commits
Lua:
addGameTask(&Game::playerReceiveNewPing, player->getID(), localPing, fps);
i did this
Code:
([playerID = player->getID()]() { g_game.playerReceiveNewPing(playerID, localPing, fps); });
but still with problem, please help
solved
Lua:
addGameTask([=, playerID = player->getID()]() { g_game.playerReceiveNewPing(playerID,localPing, fps); });
 
Last edited:
Back
Top