remove remaining compile errors
This commit is contained in:
@@ -95,7 +95,7 @@ void GameState::MoveShip(int which, double heading, double thrust, int fire)
|
||||
|
||||
ggpo_log(ggpo, "calculation of new ship coordinates: (thrust:%.4f heading:%.4f).\n", thrust, heading);
|
||||
|
||||
ship->heading = heading;
|
||||
ship->heading = (int)heading;
|
||||
|
||||
if (ship->cooldown == 0) {
|
||||
if (fire) {
|
||||
|
||||
@@ -52,11 +52,11 @@ GDIRenderer::Draw(GameState &gs, NonGameState &ngs)
|
||||
SetTextColor(hdc, _shipColors[i]);
|
||||
SelectObject(hdc, _shipPens[i]);
|
||||
DrawShip(hdc, i, gs);
|
||||
DrawConnectState(hdc, gs._ships[i], ngs.players[i], _shipColors[i]);
|
||||
DrawConnectState(hdc, gs._ships[i], ngs.players[i]);
|
||||
}
|
||||
|
||||
SetTextAlign(hdc, TA_BOTTOM | TA_CENTER);
|
||||
TextOutA(hdc, (_rc.left + _rc.right) / 2, _rc.bottom - 32, _status, strlen(_status));
|
||||
TextOutA(hdc, (_rc.left + _rc.right) / 2, _rc.bottom - 32, _status, (int)strlen(_status));
|
||||
|
||||
SetTextColor(hdc, RGB(192, 192, 192));
|
||||
RenderChecksum(hdc, 40, ngs.periodic);
|
||||
@@ -71,15 +71,15 @@ void
|
||||
GDIRenderer::RenderChecksum(HDC hdc, int y, NonGameState::ChecksumInfo &info)
|
||||
{
|
||||
char checksum[128];
|
||||
sprintf(checksum, "Frame: %04d Checksum: %08x", info.framenumber, info.checksum);
|
||||
TextOutA(hdc, (_rc.left + _rc.right) / 2, _rc.top + y, checksum, strlen(checksum));
|
||||
sprintf_s(checksum, ARRAYSIZE(checksum), "Frame: %04d Checksum: %08x", info.framenumber, info.checksum);
|
||||
TextOutA(hdc, (_rc.left + _rc.right) / 2, _rc.top + y, checksum, (int)strlen(checksum));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GDIRenderer::SetStatusText(const char *text)
|
||||
{
|
||||
strcpy(_status, text);
|
||||
strcpy_s(_status, text);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -110,7 +110,7 @@ GDIRenderer::DrawShip(HDC hdc, int which, GameState &gs)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(shape); i++) {
|
||||
int newx, newy;
|
||||
double newx, newy;
|
||||
double cost, sint, theta;
|
||||
|
||||
theta = (double)ship->heading * PI / 180;
|
||||
@@ -120,27 +120,27 @@ GDIRenderer::DrawShip(HDC hdc, int which, GameState &gs)
|
||||
newx = shape[i].x * cost - shape[i].y * sint;
|
||||
newy = shape[i].x * sint + shape[i].y * cost;
|
||||
|
||||
shape[i].x = newx + ship->position.x;
|
||||
shape[i].y = newy + ship->position.y;
|
||||
shape[i].x = (LONG)(newx + ship->position.x);
|
||||
shape[i].y = (LONG)(newy + ship->position.y);
|
||||
}
|
||||
Polyline(hdc, shape, ARRAY_SIZE(shape));
|
||||
|
||||
for (int i = 0; i < MAX_BULLETS; i++) {
|
||||
for (i = 0; i < MAX_BULLETS; i++) {
|
||||
if (ship->bullets[i].active) {
|
||||
bullet.left = ship->bullets[i].position.x - 1;
|
||||
bullet.right = ship->bullets[i].position.x + 1;
|
||||
bullet.top = ship->bullets[i].position.y - 1;
|
||||
bullet.bottom = ship->bullets[i].position.y + 1;
|
||||
bullet.left = (LONG)ship->bullets[i].position.x - 1;
|
||||
bullet.right = (LONG)ship->bullets[i].position.x + 1;
|
||||
bullet.top = (LONG)ship->bullets[i].position.y - 1;
|
||||
bullet.bottom = (LONG)ship->bullets[i].position.y + 1;
|
||||
FillRect(hdc, &bullet, _bulletBrush);
|
||||
}
|
||||
}
|
||||
SetTextAlign(hdc, alignments[which]);
|
||||
sprintf(buf, "Hits: %d", ship->score);
|
||||
TextOutA(hdc, text_offsets[which].x, text_offsets[which].y, buf, strlen(buf));
|
||||
sprintf_s(buf, ARRAYSIZE(buf), "Hits: %d", ship->score);
|
||||
TextOutA(hdc, text_offsets[which].x, text_offsets[which].y, buf, (int)strlen(buf));
|
||||
}
|
||||
|
||||
void
|
||||
GDIRenderer::DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info, COLORREF color)
|
||||
GDIRenderer::DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info)
|
||||
{
|
||||
char status[64];
|
||||
static const char *statusStrings[] = {
|
||||
@@ -154,34 +154,34 @@ GDIRenderer::DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info, C
|
||||
*status = '\0';
|
||||
switch (info.state) {
|
||||
case Connecting:
|
||||
sprintf(status, (info.type == GGPO_PLAYERTYPE_LOCAL) ? "Local Player" : "Connecting...");
|
||||
sprintf_s(status, ARRAYSIZE(status), (info.type == GGPO_PLAYERTYPE_LOCAL) ? "Local Player" : "Connecting...");
|
||||
break;
|
||||
|
||||
case Synchronizing:
|
||||
progress = info.connect_progress;
|
||||
sprintf(status, (info.type == GGPO_PLAYERTYPE_LOCAL) ? "Local Player" : "Synchronizing...");
|
||||
sprintf_s(status, ARRAYSIZE(status), (info.type == GGPO_PLAYERTYPE_LOCAL) ? "Local Player" : "Synchronizing...");
|
||||
break;
|
||||
|
||||
case Disconnected:
|
||||
sprintf(status, "Disconnected");
|
||||
sprintf_s(status, ARRAYSIZE(status), "Disconnected");
|
||||
break;
|
||||
|
||||
case Disconnecting:
|
||||
sprintf(status, "Waiting for player...");
|
||||
sprintf_s(status, ARRAYSIZE(status), "Waiting for player...");
|
||||
progress = (timeGetTime() - info.disconnect_start) * 100 / info.disconnect_timeout;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*status) {
|
||||
SetTextAlign(hdc, TA_TOP | TA_CENTER);
|
||||
TextOutA(hdc, ship.position.x, ship.position.y + PROGRESS_TEXT_OFFSET, status, strlen(status));
|
||||
TextOutA(hdc, (int)ship.position.x, (int)ship.position.y + PROGRESS_TEXT_OFFSET, status, (int)strlen(status));
|
||||
}
|
||||
if (progress >= 0) {
|
||||
HBRUSH bar = (HBRUSH)(info.state == Synchronizing ? GetStockObject(WHITE_BRUSH) : _redBrush);
|
||||
RECT rc = { ship.position.x - (PROGRESS_BAR_WIDTH / 2),
|
||||
ship.position.y + PROGRESS_BAR_TOP_OFFSET,
|
||||
ship.position.x + (PROGRESS_BAR_WIDTH / 2),
|
||||
ship.position.y + PROGRESS_BAR_TOP_OFFSET + PROGRESS_BAR_HEIGHT };
|
||||
RECT rc = { (LONG)(ship.position.x - (PROGRESS_BAR_WIDTH / 2)),
|
||||
(LONG)(ship.position.y + PROGRESS_BAR_TOP_OFFSET),
|
||||
(LONG)(ship.position.x + (PROGRESS_BAR_WIDTH / 2)),
|
||||
(LONG)(ship.position.y + PROGRESS_BAR_TOP_OFFSET + PROGRESS_BAR_HEIGHT) };
|
||||
|
||||
FrameRect(hdc, &rc, (HBRUSH)GetStockObject(GRAY_BRUSH));
|
||||
rc.right = rc.left + min(100, progress) * PROGRESS_BAR_WIDTH / 100;
|
||||
@@ -192,7 +192,7 @@ GDIRenderer::DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info, C
|
||||
|
||||
|
||||
void
|
||||
GDIRenderer::CreateGDIFont(HDC hdc)
|
||||
GDIRenderer::CreateGDIFont(HDC)
|
||||
{
|
||||
_font = CreateFont(-12,
|
||||
0, // Width Of Font
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
protected:
|
||||
void RenderChecksum(HDC hdc, int y, NonGameState::ChecksumInfo &info);
|
||||
void DrawShip(HDC hdc, int which, GameState &gamestate);
|
||||
void DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info, COLORREF color);
|
||||
void DrawConnectState(HDC hdc, Ship &ship, PlayerConnectionInfo &info);
|
||||
void CreateGDIFont(HDC hdc);
|
||||
|
||||
HFONT _font;
|
||||
|
||||
@@ -159,7 +159,7 @@ ggpoutil_perfmon_toggle()
|
||||
void
|
||||
ggpoutil_perfmon_update(GGPOSession *ggpo, GGPOPlayerHandle players[], int num_players)
|
||||
{
|
||||
GGPONetworkStats stats;
|
||||
GGPONetworkStats stats = { 0 };
|
||||
int i;
|
||||
|
||||
_num_players = num_players;
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "vectorwar.h"
|
||||
#include "ggpo_perfmon.h"
|
||||
|
||||
int local_port, num_players, num_spectators;
|
||||
|
||||
LRESULT CALLBACK
|
||||
MainWindowProc(HWND hwnd,
|
||||
UINT uMsg,
|
||||
@@ -98,14 +96,15 @@ Syntax()
|
||||
}
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
_In_opt_ HINSTANCE,
|
||||
_In_ LPWSTR,
|
||||
_In_ int)
|
||||
{
|
||||
HWND hwnd = CreateMainWindow(hInstance);
|
||||
int offset = 1, local_player = 0;
|
||||
WSADATA wd = { 0 };
|
||||
wchar_t wide_ip_buffer[128];
|
||||
unsigned int wide_ip_buffer_size = (unsigned int)ARRAYSIZE(wide_ip_buffer);
|
||||
|
||||
WSAStartup(MAKEWORD(2, 2), &wd);
|
||||
POINT window_offsets[] = {
|
||||
@@ -123,18 +122,18 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
Syntax();
|
||||
return 1;
|
||||
}
|
||||
local_port = _wtoi(__wargv[offset++]);
|
||||
num_players = _wtoi(__wargv[offset++]);
|
||||
unsigned short local_port = (unsigned short)_wtoi(__wargv[offset++]);
|
||||
int num_players = _wtoi(__wargv[offset++]);
|
||||
if (num_players < 0 || __argc < offset + num_players) {
|
||||
Syntax();
|
||||
}
|
||||
if (wcscmp(__wargv[offset], L"spectate") == 0) {
|
||||
char host_ip[128];
|
||||
int host_port;
|
||||
if (swscanf(__wargv[offset+1], L"%[^:]:%d", wide_ip_buffer, &host_port) != 2) {
|
||||
unsigned short host_port;
|
||||
if (swscanf_s(__wargv[offset+1], L"%[^:]:%hu", wide_ip_buffer, wide_ip_buffer_size, &host_port) != 2) {
|
||||
Syntax();
|
||||
}
|
||||
wcstombs(host_ip, wide_ip_buffer, sizeof(host_ip));
|
||||
wcstombs_s(nullptr, host_ip, ARRAYSIZE(host_ip), wide_ip_buffer, _TRUNCATE);
|
||||
VectorWar_InitSpectator(hwnd, local_port, num_players, host_ip, host_port);
|
||||
} else {
|
||||
GGPOPlayer players[GGPO_MAX_SPECTATORS + GGPO_MAX_PLAYERS];
|
||||
@@ -152,21 +151,21 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
|
||||
players[i].type = GGPO_PLAYERTYPE_REMOTE;
|
||||
if (swscanf(arg, L"%[^:]:%hd", wide_ip_buffer, &players[i].u.remote.port) != 2) {
|
||||
if (swscanf_s(arg, L"%[^:]:%hd", wide_ip_buffer, wide_ip_buffer_size, &players[i].u.remote.port) != 2) {
|
||||
Syntax();
|
||||
return 1;
|
||||
}
|
||||
wcstombs(players[i].u.remote.ip_address, wide_ip_buffer, sizeof(players[i].u.remote.ip_address));
|
||||
wcstombs_s(nullptr, players[i].u.remote.ip_address, ARRAYSIZE(players[i].u.remote.ip_address), wide_ip_buffer, _TRUNCATE);
|
||||
}
|
||||
// these are spectators...
|
||||
num_spectators = 0;
|
||||
int num_spectators = 0;
|
||||
while (offset < __argc) {
|
||||
players[i].type = GGPO_PLAYERTYPE_SPECTATOR;
|
||||
if (swscanf(__wargv[offset++], L"%[^:]:%hd", wide_ip_buffer, &players[i].u.remote.port) != 2) {
|
||||
if (swscanf_s(__wargv[offset++], L"%[^:]:%hd", wide_ip_buffer, wide_ip_buffer_size, &players[i].u.remote.port) != 2) {
|
||||
Syntax();
|
||||
return 1;
|
||||
}
|
||||
wcstombs(players[i].u.remote.ip_address, wide_ip_buffer, sizeof(players[i].u.remote.ip_address));
|
||||
wcstombs_s(nullptr, players[i].u.remote.ip_address, ARRAYSIZE(players[i].u.remote.ip_address), wide_ip_buffer, _TRUNCATE);
|
||||
i++;
|
||||
num_spectators++;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ fletcher32_checksum(short *data, size_t len)
|
||||
int sum1 = 0xffff, sum2 = 0xffff;
|
||||
|
||||
while (len) {
|
||||
unsigned tlen = len > 360 ? 360 : len;
|
||||
size_t tlen = len > 360 ? 360 : len;
|
||||
len -= tlen;
|
||||
do {
|
||||
sum1 += *data++;
|
||||
@@ -50,7 +50,7 @@ fletcher32_checksum(short *data, size_t len)
|
||||
* so just return true.
|
||||
*/
|
||||
bool __cdecl
|
||||
vw_begin_game_callback(const char *name)
|
||||
vw_begin_game_callback(const char *)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ vw_on_event_callback(GGPOEvent *info)
|
||||
* during a rollback.
|
||||
*/
|
||||
bool __cdecl
|
||||
vw_advance_frame_callback(int flags)
|
||||
vw_advance_frame_callback(int)
|
||||
{
|
||||
int inputs[MAX_SHIPS] = { 0 };
|
||||
int disconnect_flags;
|
||||
@@ -137,7 +137,7 @@ vw_load_game_state_callback(unsigned char *buffer, int len)
|
||||
* buffer and len parameters.
|
||||
*/
|
||||
bool __cdecl
|
||||
vw_save_game_state_callback(unsigned char **buffer, int *len, int *checksum, int frame)
|
||||
vw_save_game_state_callback(unsigned char **buffer, int *len, int *checksum, int)
|
||||
{
|
||||
*len = sizeof(gs);
|
||||
*buffer = (unsigned char *)malloc(*len);
|
||||
@@ -155,9 +155,10 @@ vw_save_game_state_callback(unsigned char **buffer, int *len, int *checksum, int
|
||||
* Log the gamestate. Used by the synctest debugging tool.
|
||||
*/
|
||||
bool __cdecl
|
||||
vw_log_game_state(char *filename, unsigned char *buffer, int len)
|
||||
vw_log_game_state(char *filename, unsigned char *buffer, int)
|
||||
{
|
||||
FILE *fp = fopen(filename, "w");
|
||||
FILE* fp = nullptr;
|
||||
fopen_s(&fp, filename, "w");
|
||||
if (fp) {
|
||||
GameState *gamestate = (GameState *)buffer;
|
||||
fprintf(fp, "GameState object.\n");
|
||||
@@ -205,7 +206,7 @@ vw_free_buffer(void *buffer)
|
||||
* the video renderer and creates a new network session.
|
||||
*/
|
||||
void
|
||||
VectorWar_Init(HWND hwnd, int localport, int num_players, GGPOPlayer *players, int num_spectators)
|
||||
VectorWar_Init(HWND hwnd, unsigned short localport, int num_players, GGPOPlayer *players, int num_spectators)
|
||||
{
|
||||
GGPOErrorCode result;
|
||||
renderer = new GDIRenderer(hwnd);
|
||||
@@ -262,7 +263,7 @@ VectorWar_Init(HWND hwnd, int localport, int num_players, GGPOPlayer *players, i
|
||||
* Create a new spectator session
|
||||
*/
|
||||
void
|
||||
VectorWar_InitSpectator(HWND hwnd, int localport, int num_players, char *host_ip, int host_port)
|
||||
VectorWar_InitSpectator(HWND hwnd, unsigned short localport, int num_players, char *host_ip, unsigned short host_port)
|
||||
{
|
||||
GGPOErrorCode result;
|
||||
renderer = new GDIRenderer(hwnd);
|
||||
@@ -302,9 +303,9 @@ VectorWar_DisconnectPlayer(int player)
|
||||
char logbuf[128];
|
||||
GGPOErrorCode result = ggpo_disconnect_player(ggpo, ngs.players[player].handle);
|
||||
if (GGPO_SUCCEEDED(result)) {
|
||||
sprintf(logbuf, "Disconnected player %d.\n", player);
|
||||
sprintf_s(logbuf, ARRAYSIZE(logbuf), "Disconnected player %d.\n", player);
|
||||
} else {
|
||||
sprintf(logbuf, "Error while disconnecting player (err:%d).\n", result);
|
||||
sprintf_s(logbuf, ARRAYSIZE(logbuf), "Error while disconnecting player (err:%d).\n", result);
|
||||
}
|
||||
renderer->SetStatusText(logbuf);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ enum VectorWarInputs {
|
||||
INPUT_BOMB = (1 << 5),
|
||||
};
|
||||
|
||||
void VectorWar_Init(HWND hwnd, int localport, int num_players, GGPOPlayer *players, int num_spectators);
|
||||
void VectorWar_InitSpectator(HWND hwnd, int localport, int num_players, char *host_ip, int host_port);
|
||||
void VectorWar_Init(HWND hwnd, unsigned short localport, int num_players, GGPOPlayer *players, int num_spectators);
|
||||
void VectorWar_InitSpectator(HWND hwnd, unsigned short localport, int num_players, char *host_ip, unsigned short host_port);
|
||||
void VectorWar_DrawCurrentFrame();
|
||||
void VectorWar_AdvanceFrame(int inputs[], int disconnect_flags);
|
||||
void VectorWar_RunFrame(HWND hwnd);
|
||||
|
||||
@@ -404,9 +404,9 @@ GGPO_API GGPOErrorCode __cdecl ggpo_start_spectating(GGPOSession **session,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
unsigned int local_port,
|
||||
unsigned short local_port,
|
||||
char *host_ip,
|
||||
unsigned int host_port);
|
||||
unsigned short host_port);
|
||||
|
||||
/*
|
||||
* ggpo_close_session --
|
||||
|
||||
Reference in New Issue
Block a user