RingRacers/src/d_ticcmd.h
Sally Coolatta abde576c58 Enforce const in bot ticcmds
There were a few remaining cases of bot ticcmd generation editing player structures directly. Fix all of this and make as much of it pass const player pointers so this physically can't be allowed to happen ever again. Appears to improve bot sync in netgames & demos bot support, but I have not tested extensively.
2023-12-22 23:28:08 -05:00

99 lines
2.5 KiB
C

// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2020 by Sonic Team Junior.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file d_ticcmd.h
/// \brief Button/action code definitions, ticcmd_t
#ifndef __D_TICCMD__
#define __D_TICCMD__
#include "m_fixed.h"
#include "doomtype.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUG__
#pragma interface
#endif
#define MAXPREDICTTICS 12
// Button/action code definitions.
typedef enum
{
BT_ACCELERATE = 1, // Accelerate
BT_DRIFT = 1<<2, // Drift (direction is cmd->turning)
BT_BRAKE = 1<<3, // Brake
BT_ATTACK = 1<<4, // Use Item
BT_LOOKBACK = 1<<5, // Look Backward
BT_RESPAWN = 1<<6, // Respawn
BT_VOTE = 1<<7, // Vote
BT_EBRAKEMASK = (BT_ACCELERATE|BT_BRAKE),
BT_SPINDASHMASK = (BT_ACCELERATE|BT_BRAKE|BT_DRIFT),
// free: 1<<8 to 1<<12
// Lua garbage, replace with freeslottable buttons some day
BT_LUAA = 1<<13,
BT_LUAB = 1<<14,
BT_LUAC = 1<<15,
} buttoncode_t;
// The data sampled per tick (single player)
// and transmitted to other peers (multiplayer).
// Mainly movements/button commands per game tick,
// plus a checksum for internal state consistency.
// ticcmd turning bits
#define TICCMD_REDUCE 16
// ticcmd latency mask
#define TICCMD_LATENCYMASK 0xFF
// ticcmd flags
#define TICCMD_RECEIVED (0x01) /* Actual tic recieved from client */
#define TICCMD_TYPING (0x02) /* chat window or console open */
#define TICCMD_KEYSTROKE (0x04) /* chat character input */
#define TICCMD_BOT (0x80) /* generated by bot, demos write bot variables */
#if defined(_MSC_VER)
#pragma pack(1)
#endif
struct ticcmd_t
{
SINT8 forwardmove; // -MAXPLMOVE to MAXPLMOVE (50)
INT16 turning; // Turn speed
INT16 angle; // Predicted angle, use me if you can!
INT16 throwdir; // Aiming direction
INT16 aiming; // vertical aiming, see G_BuildTicCmd
UINT16 buttons;
UINT8 latency; // Netgames: how many tics ago was this ticcmd generated from this player's end?
UINT8 flags;
struct
{
SINT8 turnconfirm;
SINT8 spindashconfirm;
SINT8 itemconfirm;
} bot;
} ATTRPACK;
#if defined(_MSC_VER)
#pragma pack()
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif