From 98d59eb2219511ad8c6c70f565abe60cff32ad53 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Tue, 29 Nov 2022 19:42:09 +0400 Subject: [PATCH] Added more comments --- launcher/lobby/lobby.h | 120 ++++++++++++++++++++---- launcher/lobby/lobby_moc.cpp | 9 ++ launcher/lobby/lobby_moc.h | 9 ++ launcher/lobby/lobbyroomrequest_moc.cpp | 9 ++ launcher/lobby/lobbyroomrequest_moc.h | 9 ++ 5 files changed, 139 insertions(+), 17 deletions(-) diff --git a/launcher/lobby/lobby.h b/launcher/lobby/lobby.h index d42f21d9c..3e11e3bbc 100644 --- a/launcher/lobby/lobby.h +++ b/launcher/lobby/lobby.h @@ -32,29 +32,115 @@ enum ProtocolConsts const QMap ProtocolStrings { - //client consts - {GREETING, "%1%2%3"}, //protocol_version byte, encoding bytes, encoding, name, version + //=== client commands === + + //handshaking with server + //%1: first byte is protocol_version, then size of encoding string in bytes, then encoding string + //%2: client name + //%3: VCMI version + {GREETING, "%1%2%3"}, + + //[unsupported] autorization with username + //%1: username {USERNAME, "%1"}, + + //sending message to the chat + //%1: message text {MESSAGE, "%1"}, - {CREATE, "%1%2%3%4"}, //last placeholder for the mods - {JOIN, "%1%2%3"}, //last placeholder for the mods - {LEAVE, "%1"}, //session - {KICK, "%1"}, //player username - {READY, "%1"}, //session - {FORCESTART, "%1"}, //session + + //create new room + //%1: room name + //%2: password for the room + //%3: max number of players + //%4: mods used by host + // each mod has a format modname&modversion, mods should be separated by ; symbol + {CREATE, "%1%2%3%4"}, + + //join to the room + //%1: room name + //%2: password for the room + //%3: list of mods used by player + // each mod has a format modname&modversion, mods should be separated by ; symbol + {JOIN, "%1%2%3"}, + + //leave the room + //%1: room name + {LEAVE, "%1"}, + + //kick user from the current room + //%1: player username + {KICK, "%1"}, + + //signal that player is ready for game + //%1: room name + {READY, "%1"}, + + //[unsupported] start session immediately + //%1: room name + {FORCESTART, "%1"}, - //server consts + //=== server commands === + //server commands are started from :>>, arguments are enumerated by : symbol + + //new session was created + //arg[0]: room name {CREATED, "CREATED"}, - {SESSIONS, "SESSIONS"}, //amount:session_name:joined_players:total_players:is_protected - {JOINED, "JOIN"}, //session_name:username - {KICKED, "KICK"}, //session_name:username - {START, "START"}, //session_name:uuid - {HOST, "HOST"}, //host_uuid:players_count + + //list of existing sessions + //arg[0]: amount of sessions, following arguments depending on it + //arg[x]: session name + //arg[x+1]: amount of players in the session + //arg[x+2]: total amount of players allowed + //arg[x+3]: True if session is protected by password + {SESSIONS, "SESSIONS"}, + + //user has joined to the session + //arg[0]: session name + //arg[1]: username (who was joined) + {JOINED, "JOIN"}, + + //user has left the session + //arg[0]: session name + //arg[1]: username (who has left) + {KICKED, "KICK"}, + + //session has been started + //arg[0]: session name + //arg[1]: uuid to be used for connection + {START, "START"}, + + //host ownership for the game session + //arg[0]: uuid to be used by vcmiserver + //arg[1]: amount of players (clients) to be connected + {HOST, "HOST"}, + + //room status + //arg[0]: amount of players, following arguments depending on it + //arg[x]: player username + //arg[x+1]: True if player is ready {STATUS, "STATUS"}, //joined_players:player_name:is_ready + + //server error + //arg[0]: error message {SRVERROR, "ERROR"}, - {MODS, "MODS"}, //amount:modname:modversion - {CLIENTMODS, "MODSOTHER"}, //username:amount:modname:modversion - {CHAT, "MSG"} //username:message + + //mods used in the session by host player + //arg[0]: amount of mods, following arguments depending on it + //arg[x]: mod name + //arg[x+1]: mod version + {MODS, "MODS"}, + + //mods used by user + //arg[0]: username + //arg[1]: amount of mods, following arguments depending on it + //arg[x]: mod name + //arg[x+1]: mod version + {CLIENTMODS, "MODSOTHER"}, + + //received chat message + //arg[0]: sender username + //arg[1]: message text + {CHAT, "MSG"} }; class ServerCommand diff --git a/launcher/lobby/lobby_moc.cpp b/launcher/lobby/lobby_moc.cpp index 2f258d3ca..ca3218c3b 100644 --- a/launcher/lobby/lobby_moc.cpp +++ b/launcher/lobby/lobby_moc.cpp @@ -1,3 +1,12 @@ +/* + * lobby_moc.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ #include "StdInc.h" #include "main.h" #include "lobby_moc.h" diff --git a/launcher/lobby/lobby_moc.h b/launcher/lobby/lobby_moc.h index c794c5df5..364500223 100644 --- a/launcher/lobby/lobby_moc.h +++ b/launcher/lobby/lobby_moc.h @@ -1,3 +1,12 @@ +/* + * lobby_moc.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ #pragma once #include #include "lobby.h" diff --git a/launcher/lobby/lobbyroomrequest_moc.cpp b/launcher/lobby/lobbyroomrequest_moc.cpp index 234f05364..ec42e182d 100644 --- a/launcher/lobby/lobbyroomrequest_moc.cpp +++ b/launcher/lobby/lobbyroomrequest_moc.cpp @@ -1,3 +1,12 @@ +/* + * lobbyroomrequest_moc.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ #include "lobbyroomrequest_moc.h" #include "ui_lobbyroomrequest_moc.h" diff --git a/launcher/lobby/lobbyroomrequest_moc.h b/launcher/lobby/lobbyroomrequest_moc.h index 236d5564e..4595c5ef5 100644 --- a/launcher/lobby/lobbyroomrequest_moc.h +++ b/launcher/lobby/lobbyroomrequest_moc.h @@ -1,3 +1,12 @@ +/* + * lobbyroomrequest_moc.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ #ifndef LOBBYROOMREQUEST_MOC_H #define LOBBYROOMREQUEST_MOC_H