Skip to content

Commit

Permalink
gamenet: Fix cl_is_ddnet_legacy message
Browse files Browse the repository at this point in the history
  • Loading branch information
heinrich5991 committed Jul 12, 2023
1 parent a337133 commit c61dda2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions gamenet/ddnet/src/msg/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,9 @@ pub struct ClCallVote<'a> {
}

#[derive(Clone, Copy)]
pub struct ClIsDdnetLegacy;
pub struct ClIsDdnetLegacy {
pub ddnet_version: i32,
}

#[derive(Clone, Copy)]
pub struct SvDdraceTimeLegacy {
Expand Down Expand Up @@ -1537,17 +1539,21 @@ impl<'a> fmt::Debug for ClCallVote<'a> {

impl ClIsDdnetLegacy {
pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClIsDdnetLegacy, Error> {
let result = Ok(ClIsDdnetLegacy);
let result = Ok(ClIsDdnetLegacy {
ddnet_version: _p.read_int(warn)?,
});
_p.finish(warn);
result
}
pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
_p.write_int(self.ddnet_version)?;
Ok(_p.written())
}
}
impl fmt::Debug for ClIsDdnetLegacy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("ClIsDdnetLegacy")
.field("ddnet_version", &self.ddnet_version)
.finish()
}
}
Expand Down
3 changes: 2 additions & 1 deletion gamenet/generate/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,13 @@ def fix_network(network, version):
TUNE_PARAMS = ("sv", "tune", "params")
EXTRA_PROJECTILE = ("sv", "extra", "projectile")
IS_DDNET = ("cl", "is", "ddnet")
IS_DDNET_LEGACY = ("cl", "is", "ddnet", "legacy")
for i in range(len(network.Messages)):
if network.Messages[i].name == TUNE_PARAMS:
network.Messages[i] = NetMessage("SvTuneParams", [NetTuneParam(n) for n in TUNE_PARAM_NAMES[version]])
elif network.Messages[i].name == EXTRA_PROJECTILE:
network.Messages[i].values.append(NetObjectMember("projectile", ("projectile",)))
elif network.Messages[i].name == IS_DDNET:
elif network.Messages[i].name in (IS_DDNET, IS_DDNET_LEGACY):
network.Messages[i].values.append(NetIntAny("ddnet_version"))
extra_msg_generation = set(v.type_name for m in network.Messages + network.System for v in m.values if isinstance(v, NetObjectMember))
for i in range(len(network.Objects)):
Expand Down
4 changes: 3 additions & 1 deletion gamenet/generate/spec/ddnet-16.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@
{
"id": 26,
"name": ["cl", "is", "ddnet", "legacy"],
"members": [],
"members": [
{"name": ["ddnet", "version"], "type": {"kind": "int32"}}
],
"attributes": []
},
{
Expand Down
4 changes: 3 additions & 1 deletion gamenet/generate/spec/ddnet-16.7.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@
{
"id": 26,
"name": ["cl", "is", "ddnet", "legacy"],
"members": [],
"members": [
{"name": ["ddnet", "version"], "type": {"kind": "int32"}}
],
"attributes": []
},
{
Expand Down

0 comments on commit c61dda2

Please sign in to comment.