Code Monkey home page Code Monkey logo

Comments (1)

Kurtsley avatar Kurtsley commented on July 21, 2024

I think I've found the cause of this issue and would like some feedback.

It looks like this is the block of code responsible for the player selection menu input:

cdogs-sdl/src/prep.c

Lines 410 to 440 in fbac574

// Menu input
int idx = 0;
const bool useMenuCmd = GetNumPlayers(PLAYER_ANY, true, true);
for (int i = 0; i < (int)gPlayerDatas.size; i++, idx++)
{
const PlayerData *p = CArrayGet(&gPlayerDatas, i);
if (!p->IsLocal)
{
idx--;
continue;
}
if (p->inputDevice != INPUT_DEVICE_UNSET)
{
MenuSystem *ms = &pData->menus[idx].ms;
if (ms->current->customPostUpdateFunc)
{
ms->current->customPostUpdateFunc(
ms->current, ms->current->customPostUpdateData);
}
MenuUpdateMouse(ms);
if (useMenuCmd)
{
cmds[idx] |=
GetMenuCmd(&gEventHandlers, ms->current->mouseHover);
}
if (!MenuIsExit(ms) && cmds[idx])
{
MenuProcessCmd(ms, cmds[idx]);
}
}
}

When player one pressed Up for example, the command was sent twice which ended up affecting the second player. I believe this is caused by the GetMenuCmd function at line 433. The input for this menu is processed at line 437 if there has not been an exit command.

Why does this block get called as well?

cdogs-sdl/src/prep.c

Lines 430 to 434 in fbac574

if (useMenuCmd)
{
cmds[idx] |=
GetMenuCmd(&gEventHandlers, ms->current->mouseHover);
}

It looks like useMenuCmd checks if there are any local, alive players. If that is the case, process their key presses. GetMenuCmd and MenuProcessCmd both process the player 1 key presses. More specifically, it looks like GetMenuCmd controls both player menus in the player selection screen.

TLDR removing the above block which calls GetMenuCmd along with the useMenuCmd check fixes this issue.

from cdogs-sdl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.