mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-05 13:20:56 +00:00
- implemented the framework for freeform network commands.
Unlike ZDoom this uses callbacks for implementation to keep game specific parts encapsulated to the game code.
This commit is contained in:
parent
b3d89a6a0b
commit
66d8eae8e1
2 changed files with 24 additions and 27 deletions
|
@ -1931,45 +1931,35 @@ uint8_t *FDynamicBuffer::GetData (int *len)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NetCommandHandler nethandlers[DEM_MAX];
|
||||||
|
|
||||||
|
void Net_SetCommandHandler(EDemoCommand cmd, NetCommandHandler handler) noexcept
|
||||||
|
{
|
||||||
|
assert(cmd >= 0 && cmd < DEM_MAX);
|
||||||
|
if (cmd >= 0 && cmd < DEM_MAX) nethandlers[cmd] = handler;
|
||||||
|
}
|
||||||
|
|
||||||
// [RH] Execute a special "ticcmd". The type byte should
|
// [RH] Execute a special "ticcmd". The type byte should
|
||||||
// have already been read, and the stream is positioned
|
// have already been read, and the stream is positioned
|
||||||
// at the beginning of the command's actual data.
|
// at the beginning of the command's actual data.
|
||||||
void Net_DoCommand (int type, uint8_t **stream, int player)
|
void Net_DoCommand (int cmd, uint8_t **stream, int player)
|
||||||
{
|
{
|
||||||
#if 0
|
assert(cmd >= 0 && cmd < DEM_MAX);
|
||||||
uint8_t pos = 0;
|
if (cmd >= 0 && cmd < DEM_MAX && nethandlers[cmd])
|
||||||
char *s = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
|
nethandlers[cmd](stream, false);
|
||||||
default:
|
|
||||||
I_Error ("Unknown net command: %d", type);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (s)
|
I_Error("Unknown net command: %d", cmd);
|
||||||
delete[] s;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Net_SkipCommand (int type, uint8_t **stream)
|
void Net_SkipCommand (int cmd, uint8_t **stream)
|
||||||
{
|
{
|
||||||
#if 0
|
if (cmd >= 0 && cmd < DEM_MAX && nethandlers[cmd])
|
||||||
uint8_t t;
|
|
||||||
size_t skip = 0;
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
{
|
||||||
|
nethandlers[cmd](stream, true);
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*stream += skip;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the network ticker after finishing a lengthy operation.
|
// Reset the network ticker after finishing a lengthy operation.
|
||||||
|
|
|
@ -88,8 +88,15 @@ enum EDemoCommand
|
||||||
DEM_BAD, // 0 Bad command
|
DEM_BAD, // 0 Bad command
|
||||||
DEM_USERCMD,
|
DEM_USERCMD,
|
||||||
DEM_EMPTYUSERCMD,
|
DEM_EMPTYUSERCMD,
|
||||||
|
DEM_CHEAT_GOD,
|
||||||
|
|
||||||
|
DEM_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void(*NetCommandHandler)(uint8_t **stream, bool skip);
|
||||||
|
|
||||||
|
void Net_SetCommandHandler(EDemoCommand cmd, NetCommandHandler handler) noexcept;
|
||||||
|
|
||||||
void StartChunk (int id, uint8_t **stream);
|
void StartChunk (int id, uint8_t **stream);
|
||||||
void FinishChunk (uint8_t **stream);
|
void FinishChunk (uint8_t **stream);
|
||||||
void SkipChunk (uint8_t **stream);
|
void SkipChunk (uint8_t **stream);
|
||||||
|
|
Loading…
Reference in a new issue