1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
//-----------------------------------------------------------------------------
// Name: host_session_flag.cpp
// Developer: Wolfire Games LLC
// Description:
// License: Read below
//-----------------------------------------------------------------------------
//
// Copyright 2022 Wolfire Games LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//-----------------------------------------------------------------------------
#include "host_session_flag.h"
#include <Online/online.h>
namespace OnlineMessages {
HostSessionFlag::HostSessionFlag(OnlineFlags flag, bool value) :
OnlineMessageBase(OnlineMessageCategory::TRANSIENT),
flag(flag), value(value)
{
}
binn* HostSessionFlag::Serialize(void* object) {
HostSessionFlag* hsf = static_cast<HostSessionFlag*>(object);
binn* l = binn_object();
binn_object_set_uint32(l, "f", (uint32_t)hsf->flag);
binn_object_set_bool(l, "v", hsf->value);
return l;
}
void HostSessionFlag::Deserialize(void* object, binn* l) {
HostSessionFlag* hsf = static_cast<HostSessionFlag*>(object);
uint32_t flag;
binn_object_get_uint32(l, "f", &flag);
hsf->flag = (OnlineFlags)flag;
BOOL value;
binn_object_get_bool(l, "v", &value);
hsf->value = (bool)value;
}
void HostSessionFlag::Execute(const OnlineMessageRef& ref, void* object, PeerID peer) {
HostSessionFlag* hsf = static_cast<HostSessionFlag*>(object);
Online* online = Online::Instance();
if(online != nullptr && online->online_session != nullptr) {
online->online_session->host_session_flags[hsf->flag] = hsf->value;
}
}
void* HostSessionFlag::Construct(void* mem) {
return new(mem) HostSessionFlag(OnlineFlags::INVALID, false);
}
void HostSessionFlag::Destroy(void* object) {
HostSessionFlag* hsf = static_cast<HostSessionFlag*>(object);
hsf->~HostSessionFlag();
}
}
|