From 4582b44eb3de49d454658f272c2e66e22e2b3c6a Mon Sep 17 00:00:00 2001 From: Oskar Strengbohm Date: Sat, 27 Apr 2024 21:30:57 +0200 Subject: [PATCH] misc: pstring: Refactor dependents. --- 2dlib/pentext.cpp | 14 +++++++------- Descent3/DllWrappers.cpp | 8 +++++--- Descent3/TelComEffects.cpp | 8 +++++--- Descent3/dedicated_server.cpp | 9 ++++++--- Descent3/huddisplay.cpp | 16 +++++++--------- Descent3/hudmessage.cpp | 30 +++++++++++++++--------------- Descent3/newui_core.cpp | 9 +++++---- Descent3/pilot.cpp | 7 ++++--- dd_grwin32/ddgrWin32Init.cpp | 14 +++++++------- dd_sndlib/ssl_lib.cpp | 10 ++++++---- ddio_win/winforcefeedback.cpp | 9 +++++---- ddio_win/winio.cpp | 10 ++++++---- grtext/grtext.cpp | 14 +++++++------- legacy/FontEditor/FontCreate.cpp | 9 ++++----- legacy/editor/Erooms.cpp | 10 +++++----- legacy/editor/MainFrm.cpp | 15 ++++++++------- legacy/editor/editor.cpp | 8 +++++--- manage/manage.cpp | 11 ++++++----- misc/error.cpp | 18 +++++++++--------- misc/logfile.cpp | 10 +++++----- win32/wincon.cpp | 10 +++++----- win32/winmono.cpp | 19 +++++++++---------- 22 files changed, 141 insertions(+), 127 deletions(-) diff --git a/2dlib/pentext.cpp b/2dlib/pentext.cpp index 8188a84b..710f76f1 100644 --- a/2dlib/pentext.cpp +++ b/2dlib/pentext.cpp @@ -81,11 +81,11 @@ * $NoKeywords: $ */ -#include -#include +#include +#include + #include #include -#include "pstring.h" #include "gr.h" #include "mono.h" #include "renderer.h" @@ -115,11 +115,11 @@ void grViewport::get_font(char *fontname, int size) { // --------------------------------------------------------------------------- int grViewport::printf(grTextAlign align, int x, int y, char *fmt, ...) { - va_list arglist; + std::va_list arglist; int len; va_start(arglist, fmt); - len = Pvsprintf(Str_buf, STR_BUF_SIZE, fmt, arglist); + len = std::vsnprintf(Str_buf, STR_BUF_SIZE, fmt, arglist); va_end(arglist); if (len < 0) return 0; @@ -128,11 +128,11 @@ int grViewport::printf(grTextAlign align, int x, int y, char *fmt, ...) { } int grViewport::printf(int x, int y, char *fmt, ...) { - va_list arglist; + std::va_list arglist; int len; va_start(arglist, fmt); - len = Pvsprintf(Str_buf, STR_BUF_SIZE, fmt, arglist); + len = std::vsnprintf(Str_buf, STR_BUF_SIZE, fmt, arglist); va_end(arglist); if (len < 0) return 0; diff --git a/Descent3/DllWrappers.cpp b/Descent3/DllWrappers.cpp index 155662a5..e4f26ff7 100644 --- a/Descent3/DllWrappers.cpp +++ b/Descent3/DllWrappers.cpp @@ -16,9 +16,11 @@ * along with this program. If not, see . */ +#include +#include + #include "DllWrappers.h" #include "pserror.h" -#include "pstring.h" #include "cfile.h" #include "gamefont.h" #include "grdefs.h" @@ -99,9 +101,9 @@ void MonoPrintf(int n, char *format, ...) { #ifndef RELEASE char tempbuffer[300]; - va_list ap; + std::va_list ap; va_start(ap, format); - Pvsprintf(tempbuffer, 300, format, ap); + std::vsnprintf(tempbuffer, 300, format, ap); va_end(ap); Debug_ConsolePrintf(n, tempbuffer); diff --git a/Descent3/TelComEffects.cpp b/Descent3/TelComEffects.cpp index 10cb7947..41beda8f 100644 --- a/Descent3/TelComEffects.cpp +++ b/Descent3/TelComEffects.cpp @@ -133,8 +133,10 @@ * $NoKeywords: $ */ +#include +#include + #include "TelComEffects.h" -#include "pstring.h" #include "mem.h" #include "vecmat.h" #include @@ -682,9 +684,9 @@ int FindButtonEffectByXY(int x, int y, int screen) { char *format(const char *fmt, ...) { static char tempbuffer[8192]; - va_list ap; + std::va_list ap; va_start(ap, fmt); - Pvsprintf(tempbuffer, sizeof (tempbuffer), fmt, ap); + std::vsnprintf(tempbuffer, sizeof(tempbuffer), fmt, ap); va_end(ap); return tempbuffer; } diff --git a/Descent3/dedicated_server.cpp b/Descent3/dedicated_server.cpp index b537e703..8a40ecac 100644 --- a/Descent3/dedicated_server.cpp +++ b/Descent3/dedicated_server.cpp @@ -102,6 +102,9 @@ * $NoKeywords: $ */ +#include +#include + #include #include @@ -555,7 +558,7 @@ void SetCVarString(int index, const char *val) { if (to_whom != MULTI_SEND_MESSAGE_ALL) val = msg; - Psprintf(str, sizeof(str), TXT_HUDSAY, Players[Player_num].callsign, val); + std::snprintf(str, sizeof(str), TXT_HUDSAY, Players[Player_num].callsign, val); MultiSendMessageFromServer(GR_RGB(0, 128, 255), str, to_whom); @@ -770,10 +773,10 @@ void PrintDedicatedMessage(const char *fmt, ...) { return; char buf[CON_MAX_STRINGLEN]; - va_list args; + std::va_list args; va_start(args, fmt); - Pvsprintf(buf, CON_MAX_STRINGLEN, fmt, args); + std::vsnprintf(buf, CON_MAX_STRINGLEN, fmt, args); va_end(args); con_Printf(buf); diff --git a/Descent3/huddisplay.cpp b/Descent3/huddisplay.cpp index 4e24be12..d91a3b90 100644 --- a/Descent3/huddisplay.cpp +++ b/Descent3/huddisplay.cpp @@ -220,7 +220,9 @@ * $NoKeywords: $ */ -#include "pstring.h" +#include +#include + #include "hud.h" #include "grtext.h" #include "gamefont.h" @@ -236,10 +238,6 @@ #include "multi.h" #include "render.h" -#include -#include - - #include ////////////////////////////////////////////////////////////////////////////// @@ -890,11 +888,11 @@ void RenderHUDQuad(int x, int y, int w, int h, float u0, float v0, float u1, flo // renders text, scaled, alphaed, saturated, void RenderHUDText(ddgr_color col, ubyte alpha, int sat_count, int x, int y, const char *fmt, ...) { - va_list arglist; + std::va_list arglist; char buf[128]; va_start(arglist, fmt); - Pvsprintf(buf, 128, fmt, arglist); + std::vsnprintf(buf, 128, fmt, arglist); va_end(arglist); RenderHUDTextFlagsNoFormat(0, col, alpha, sat_count, x, y, buf); @@ -926,12 +924,12 @@ void RenderHUDTextFlagsNoFormat(int flags, ddgr_color col, ubyte alpha, int sat_ // renders text, scaled, alphaed, saturated, void RenderHUDTextFlags(int flags, ddgr_color col, ubyte alpha, int sat_count, int x, int y, const char *fmt, ...) { - va_list arglist; + std::va_list arglist; char buf[128]; int i; va_start(arglist, fmt); - Pvsprintf(buf, 128, fmt, arglist); + std::vsnprintf(buf, 128, fmt, arglist); va_end(arglist); grtext_SetAlpha(alpha); diff --git a/Descent3/hudmessage.cpp b/Descent3/hudmessage.cpp index 3b0a79ea..c079b506 100644 --- a/Descent3/hudmessage.cpp +++ b/Descent3/hudmessage.cpp @@ -322,12 +322,12 @@ * $NoKeywords: $ */ -#include +#include +#include + #include -#include #include #include -#include "pstring.h" #include "grdefs.h" #include "hud.h" #include "game.h" @@ -516,13 +516,13 @@ bool AddMultipleLinesToHUDMessages(char *temp_message, ddgr_color color) { // adds a colored hud message to the list // Returns true if message added, or false if message not (because the previous message was the same) bool AddColoredHUDMessage(ddgr_color color, const char *format, ...) { - va_list args; + std::va_list args; char *message = NULL; char *last_message = NULL; char temp_message[HUD_MESSAGE_LENGTH * 2]; va_start(args, format); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); va_end(args); if (Demo_flags == DF_RECORDING) { @@ -552,13 +552,13 @@ bool AddFilteredColoredHUDMessage(ddgr_color color, const char *format, ...) { if (Game_mode & GM_MULTI && checked_command_line) return false; // filter this message - va_list args; + std::va_list args; char *message = NULL; char *last_message = NULL; char temp_message[HUD_MESSAGE_LENGTH * 2]; va_start(args, format); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); va_end(args); if (Demo_flags == DF_RECORDING) { @@ -588,13 +588,13 @@ bool AddFilteredHUDMessage(const char *format, ...) { if (Game_mode & GM_MULTI && checked_command_line) return false; // filter this message - va_list args; + std::va_list args; char *message = NULL; char *last_message = NULL; char temp_message[HUD_MESSAGE_LENGTH * 2]; va_start(args, format); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); va_end(args); if (Demo_flags == DF_RECORDING) { @@ -612,13 +612,13 @@ bool AddFilteredHUDMessage(const char *format, ...) { // top one and move the others up // Returns true if message added, or false if message not (because the previous message was the same) bool AddHUDMessage(const char *format, ...) { - va_list args; + std::va_list args; char *message = NULL; char *last_message = NULL; char temp_message[HUD_MESSAGE_LENGTH * 2]; va_start(args, format); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); va_end(args); if (Demo_flags == DF_RECORDING) { @@ -636,13 +636,13 @@ bool AddHUDMessage(const char *format, ...) { // top one and move the others up // Returns true if message added, or false if message not (because the previous message was the same) bool AddBlinkingHUDMessage(const char *format, ...) { - va_list args; + std::va_list args; char *message = NULL; char *last_message = NULL; char temp_message[HUD_MESSAGE_LENGTH * 2]; va_start(args, format); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, format, args); va_end(args); if (Demo_flags == DF_RECORDING) { @@ -1387,12 +1387,12 @@ void StartPersistentHUDMessage(ddgr_color color, int x, int y, float time, int f // for centering on an axis, set either x or y to -1. void AddPersistentHUDMessage(ddgr_color color, int x, int y, float time, int flags, int sound_index, const char *fmt, ...) { - va_list args; + std::va_list args; char temp_message[HUD_MESSAGE_LENGTH * 2]; // start new message va_start(args, fmt); - Pvsprintf(temp_message, HUD_MESSAGE_LENGTH * 2, fmt, args); + std::vsnprintf(temp_message, HUD_MESSAGE_LENGTH * 2, fmt, args); va_end(args); if (Hud_persistent_msg_id != HUD_INVALID_ID) // already one active, so queue the new one diff --git a/Descent3/newui_core.cpp b/Descent3/newui_core.cpp index 50cbebd8..899f39a0 100644 --- a/Descent3/newui_core.cpp +++ b/Descent3/newui_core.cpp @@ -182,6 +182,9 @@ * $NoKeywords: $ */ +#include +#include + #include "newui_core.h" #include "bitmap.h" #include "mem.h" @@ -193,13 +196,11 @@ #include "application.h" #include "stringtable.h" #include "gamefont.h" -#include "pstring.h" #include "textaux.h" #include "d3music.h" #include "hlsoundlib.h" #include -#include extern void ui_DoCursor(); @@ -2035,12 +2036,12 @@ short *newuiSheet::AddSlider(const char *title, short range, short init_pos, tSl // adds a static text item void newuiSheet::AddText(const char *text, ...) { - va_list arglist; + std::va_list arglist; char buf[512]; int len; va_start(arglist, text); - len = Pvsprintf(buf, 512, text, arglist); + len = std::vsnprintf(buf, 512, text, arglist); va_end(arglist); newuiSheet::t_gadget_desc *gadget = AddGadget(-1, GADGET_STATIC_TXT, buf); diff --git a/Descent3/pilot.cpp b/Descent3/pilot.cpp index bee09b6e..484b9438 100644 --- a/Descent3/pilot.cpp +++ b/Descent3/pilot.cpp @@ -570,6 +570,8 @@ * $NoKeywords: $ */ +#include + #include #include #include @@ -598,7 +600,6 @@ #include "config.h" #include "difficulty.h" #include "PilotPicsAPI.h" -#include "pstring.h" #include "Mission.h" #include "mem.h" #include "polymodel.h" @@ -3889,14 +3890,14 @@ void ShowPilotPicDialog(pilot *Pilot) { if (ppic_id == id_list[idx]) selected_index = idx + 1; - Psprintf(temp_buffer, PILOT_STRING_SIZE + 6, "%s%d", pname, idx); + std::snprintf(temp_buffer, PILOT_STRING_SIZE + 6, "%s%d", pname, idx); list->AddItem(temp_buffer); } } else { if (ppic_id == id_list[idx]) selected_index = idx + 1; - Psprintf(temp_buffer, PILOT_STRING_SIZE + 6, "%s", pname); + std::snprintf(temp_buffer, PILOT_STRING_SIZE + 6, "%s", pname); list->AddItem(temp_buffer); } diff --git a/dd_grwin32/ddgrWin32Init.cpp b/dd_grwin32/ddgrWin32Init.cpp index 5434d2ef..a5831840 100644 --- a/dd_grwin32/ddgrWin32Init.cpp +++ b/dd_grwin32/ddgrWin32Init.cpp @@ -49,16 +49,16 @@ * $NoKeywords: $ */ +#include +#include + #include "ddgrWin32.h" #include "ddgrWin32GDI.h" #include "ddgrWin32DX.h" #include "pserror.h" -#include "pstring.h" #include #include -#include -#include /* DDGR_WIN32 Library v2.0 enhancements = concept of graphic subsystem when initializing. @@ -185,10 +185,10 @@ void ddgr_FatalError(const char *fmt, ...) { } // create whole error message - va_list arglist; + std::va_list arglist; va_start(arglist, fmt); - Pvsprintf(buf, 768, fmt, arglist); + std::vsnprintf(buf, 768, fmt, arglist); va_end(arglist); if (DDGR_subsystems[i] = !-1) { @@ -206,11 +206,11 @@ void ddgr_FatalError(const char *fmt, ...) { } void ddgr_PushError(const char *fmt, ...) { - va_list arglist; + std::va_list arglist; char buf[128]; va_start(arglist, fmt); - Pvsprintf(buf, 128, fmt, arglist); + std::vsnprintf(buf, 128, fmt, arglist); va_end(arglist); DDGR_error_msgs[DDGR_num_msgs] = new char[strlen(buf) + 1]; diff --git a/dd_sndlib/ssl_lib.cpp b/dd_sndlib/ssl_lib.cpp index 8a4c790d..d942461e 100644 --- a/dd_sndlib/ssl_lib.cpp +++ b/dd_sndlib/ssl_lib.cpp @@ -37,9 +37,11 @@ * */ +#include +#include + #include "ssl_lib.h" #include "pserror.h" -#include "pstring.h" #include @@ -57,7 +59,7 @@ void llsSystem::CheckForErrors() { } void llsSystem::ErrorText(const char *fmt, ...) { - va_list arglist; + std::va_list arglist; char buf[128]; int len, slen; @@ -69,7 +71,7 @@ void llsSystem::ErrorText(const char *fmt, ...) { strcat(m_error_text, "\n"); va_start(arglist, fmt); - len = Pvsprintf(buf, 128, fmt, arglist); + len = std::vsnprintf(buf, 128, fmt, arglist); va_end(arglist); if (len < 0) return; @@ -78,4 +80,4 @@ void llsSystem::ErrorText(const char *fmt, ...) { return; } strcat(m_error_text, buf); -} \ No newline at end of file +} diff --git a/ddio_win/winforcefeedback.cpp b/ddio_win/winforcefeedback.cpp index 0620e9d8..51b1325c 100644 --- a/ddio_win/winforcefeedback.cpp +++ b/ddio_win/winforcefeedback.cpp @@ -91,13 +91,14 @@ #if 0 +#include +#include + #include "DDAccess.h" #include -#include #include #include "pserror.h" -#include "pstring.h" #include "mono.h" #include "ddio.h" #include "ddio_win.h" @@ -1373,9 +1374,9 @@ void PrintDirectInputErrorString( HRESULT hr,const char *format, ... ) #endif char buffer[2048]; - va_list marker; + std::va_list marker; va_start(marker,format); - Pvsprintf(buffer,2048,format,marker); + std::vsnprintf(buffer,2048,format,marker); va_end(marker); strcat(buffer,": \n"); diff --git a/ddio_win/winio.cpp b/ddio_win/winio.cpp index f67b5ff4..3863b61c 100644 --- a/ddio_win/winio.cpp +++ b/ddio_win/winio.cpp @@ -104,13 +104,15 @@ // ---------------------------------------------------------------------------- // Win32 IO System Main Library Interface // ---------------------------------------------------------------------------- + +#include +#include + #include "DDAccess.h" #include -#include #include "pserror.h" -#include "pstring.h" #include "Application.h" #include "ddio_win.h" #include "ddio.h" @@ -180,10 +182,10 @@ void ddio_InternalClose() { #ifdef _DEBUG void ddio_DebugMessage(unsigned err, char *fmt, ...) { char buf[128]; - va_list arglist; + std::va_list arglist; va_start(arglist, fmt); - Pvsprintf(buf, 128, fmt, arglist); + std::vsnprintf(buf, 128, fmt, arglist); va_end(arglist); mprintf((0, "DDIO: %s\n", buf)); diff --git a/grtext/grtext.cpp b/grtext/grtext.cpp index a88648f2..4663adf9 100644 --- a/grtext/grtext.cpp +++ b/grtext/grtext.cpp @@ -146,16 +146,16 @@ * $NoKeywords: $ */ +#include +#include + #include "grtextlib.h" #include "renderer.h" #include "pserror.h" -#include "pstring.h" #include "mem.h" -#include #include -#include #include #include @@ -407,12 +407,12 @@ void grtext_SetFont(int font_handle) { // puts a formatted string in the text buffer void grtext_Printf(int x, int y, const char *fmt, ...) { - va_list arglist; + std::va_list arglist; int len; char buf[512]; va_start(arglist, fmt); - len = Pvsprintf(buf, 512, fmt, arglist); + len = std::vsnprintf(buf, 512, fmt, arglist); va_end(arglist); if (len < 0) return; @@ -426,12 +426,12 @@ int grtext_GetFont() { return Grtext_font; } // puts a centered string in the text buffer. void grtext_CenteredPrintf(int xoff, int y, const char *fmt, ...) { int new_x; - va_list arglist; + std::va_list arglist; int len; char buf[512]; va_start(arglist, fmt); - len = Pvsprintf(buf, 512, fmt, arglist); + len = std::vsnprintf(buf, 512, fmt, arglist); va_end(arglist); if (len < 0) return; diff --git a/legacy/FontEditor/FontCreate.cpp b/legacy/FontEditor/FontCreate.cpp index 7ae4a0d8..c164dfa4 100644 --- a/legacy/FontEditor/FontCreate.cpp +++ b/legacy/FontEditor/FontCreate.cpp @@ -37,6 +37,8 @@ * */ +#include +#include #include "FontEditor.h" #include "pstypes.h" @@ -44,12 +46,9 @@ #include "bitmap.h" #include "renderer.h" #include "grtext.h" -#include "pstring.h" #include "ddio.h" #include "mem.h" -#include -#include #include // Font File stuff @@ -99,12 +98,12 @@ void message_box(const char *fmt, ...) #define FIXED_MSGBOX_WIDTH (512) #define FIXED_MSGBOX_HEIGHT (128) - va_list arglist; + std::va_list arglist; char buf[512]; int len; va_start(arglist,fmt); - len = Pvsprintf(buf,512,fmt,arglist); + len = std::vsnprintf(buf,512,fmt,arglist); va_end(arglist); if (len < 0) return; diff --git a/legacy/editor/Erooms.cpp b/legacy/editor/Erooms.cpp index a923c178..5a7f69f0 100644 --- a/legacy/editor/Erooms.cpp +++ b/legacy/editor/Erooms.cpp @@ -539,9 +539,10 @@ * $NoKeywords: $ */ +#include +#include #include -#include #ifndef NEWEDITOR #include "d3edit.h" @@ -561,7 +562,6 @@ #include "trigger.h" #include "mem.h" #include "doorway.h" -#include "pstring.h" #ifndef NEWEDITOR #include "editor_lighting.h" @@ -2205,11 +2205,11 @@ int error_buf_offset; //Log an error in the room check process void CheckError(const char *str,...) { - va_list arglist; + std::va_list arglist; int nchars; va_start(arglist, str); - nchars = Pvsprintf(error_buf+error_buf_offset,BUF_LEN-error_buf_offset, str, arglist); + nchars = std::vsnprintf(error_buf+error_buf_offset,BUF_LEN-error_buf_offset, str, arglist); va_end(arglist); error_buf_offset += strlen(error_buf+error_buf_offset); @@ -3398,4 +3398,4 @@ void ListObjectsInAllLevels() } DumpTextToClipboard(error_buf); -} \ No newline at end of file +} diff --git a/legacy/editor/MainFrm.cpp b/legacy/editor/MainFrm.cpp index 6b597515..329eb6e0 100644 --- a/legacy/editor/MainFrm.cpp +++ b/legacy/editor/MainFrm.cpp @@ -761,6 +761,8 @@ * $NoKeywords: $ */ +#include +#include #include "stdafx.h" #include "editor.h" @@ -804,7 +806,6 @@ // D3 EDITOR HEADERS #include "pserror.h" -#include "pstring.h" #include "Application.h" #include "AppDatabase.h" #include "program.h" @@ -1594,10 +1595,10 @@ void EditorStatus( const char *format, ... ) { if (MFC_Main_frame) { char status_line[256]; - va_list ap; + std::va_list ap; va_start(ap, format); - Pvsprintf(status_line, 256,format, ap); + std::vsnprintf(status_line, 256,format, ap); va_end(ap); MFC_Main_frame->SetStatusMessage(status_line); @@ -1609,10 +1610,10 @@ void SplashMessage(const char *format, ...) { if (D3_splash_screen) { char status_line[256]; - va_list ap; + std::va_list ap; va_start(ap, format); - Pvsprintf(status_line, 256,format, ap); + std::vsnprintf(status_line, 256,format, ap); va_end(ap); D3_splash_screen->PutText(status_line); @@ -1625,10 +1626,10 @@ char Editor_error_message[1000]=""; //code should call this with the error message. void SetErrorMessage(const char *fmt,...) { - va_list arglist; + std::va_list arglist; va_start(arglist,fmt); - Pvsprintf(Editor_error_message,sizeof(Editor_error_message),fmt,arglist); + std::vsnprintf(Editor_error_message,sizeof(Editor_error_message),fmt,arglist); va_end(arglist); mprintf ((0,"Editor error: %s\n",Editor_error_message)); diff --git a/legacy/editor/editor.cpp b/legacy/editor/editor.cpp index 810e3253..c9609efc 100644 --- a/legacy/editor/editor.cpp +++ b/legacy/editor/editor.cpp @@ -364,6 +364,9 @@ // editor.cpp : Defines the class behaviors for the application. // +#include +#include + #include "stdafx.h" #include "editor.h" #include "MainFrm.h" @@ -376,7 +379,6 @@ #include "moveworld.h" #include "d3edit.h" #include "pserror.h" -#include "pstring.h" #include "args.h" #include "game.h" #include "trigger.h" @@ -1067,13 +1069,13 @@ bool FileDialog(CWnd *wnd, BOOL open, LPCTSTR filter, char *pathname, char *init // fmt - printf-style text & arguments void PrintToDlgItem(CDialog *dlg,int id,char *fmt,...) { - va_list arglist; + std::va_list arglist; char str[3000]; int len; CEdit *ebox; va_start(arglist,fmt); - len = Pvsprintf(str,3000,fmt,arglist); + len = std::vsnprintf(str,3000,fmt,arglist); va_end(arglist); ASSERT(len < 3000); diff --git a/manage/manage.cpp b/manage/manage.cpp index 93fc836b..447de507 100644 --- a/manage/manage.cpp +++ b/manage/manage.cpp @@ -433,8 +433,11 @@ * * $NoKeywords: $ */ + +#include +#include + #include -#include #include #include #if defined(WIN32) @@ -3078,8 +3081,6 @@ void Read256TextureNames () cfclose (infile); }*/ -#include "pstring.h" - void DataError(const char *fmt, ...) { // Got a data error! // Int3(); @@ -3094,11 +3095,11 @@ void DataError(const char *fmt, ...) { // Write to file if switch specified if (FindArg("-datacheck")) { static char last_filename[_MAX_PATH]; - va_list arglist; + std::va_list arglist; char buf[1024]; va_start(arglist, fmt); - Pvsprintf(buf, sizeof(buf), fmt, arglist); + std::vsnprintf(buf, sizeof(buf), fmt, arglist); va_end(arglist); // Open file if not already open diff --git a/misc/error.cpp b/misc/error.cpp index fe737b62..fca1dd29 100644 --- a/misc/error.cpp +++ b/misc/error.cpp @@ -64,14 +64,14 @@ * */ -#include +#include +#include + #include -#include #include #include "mono.h" #include "pserror.h" -#include "pstring.h" #include "debug.h" #include "application.h" @@ -118,14 +118,14 @@ extern int no_debug_dialog; // exits the application and prints out a standard error message void Error(const char *fmt, ...) { - va_list arglist; + std::va_list arglist; int exit_msg_len; strcpy(Exit_message, "Error: "); va_start(arglist, fmt); exit_msg_len = strlen(Exit_message); - Pvsprintf(Exit_message + exit_msg_len, MAX_MSG_LEN - exit_msg_len, fmt, arglist); + std::vsnprintf(Exit_message + exit_msg_len, MAX_MSG_LEN - exit_msg_len, fmt, arglist); va_end(arglist); snprintf(Exit_title_str, sizeof(Exit_title_str), "%s Error", App_title); @@ -242,11 +242,11 @@ void SetMessageBoxTitle(const char *title) { strncpy(Messagebox_title, title, si // Pops up a dialog box to display a message void OutrageMessageBox(const char *str, ...) { char buf[BUF_LEN]; - va_list arglist; + std::va_list arglist; int nchars; va_start(arglist, str); - nchars = Pvsprintf(buf, BUF_LEN, str, arglist); + nchars = std::vsnprintf(buf, BUF_LEN, str, arglist); va_end(arglist); if (nchars >= BUF_LEN) @@ -258,12 +258,12 @@ void OutrageMessageBox(const char *str, ...) { int OutrageMessageBox(int type, const char *str, ...) { char buf[BUF_LEN]; - va_list arglist; + std::va_list arglist; int os_flags = 0; int nchars; va_start(arglist, str); - nchars = Pvsprintf(buf, BUF_LEN, str, arglist); + nchars = std::vsnprintf(buf, BUF_LEN, str, arglist); va_end(arglist); if (type == MBOX_OK) diff --git a/misc/logfile.cpp b/misc/logfile.cpp index 5e5e99f7..fb8a42e7 100644 --- a/misc/logfile.cpp +++ b/misc/logfile.cpp @@ -16,10 +16,10 @@ * along with this program. If not, see . */ +#include +#include + #include "logfile.h" -#include "pstring.h" -#include -#include #ifdef _DEBUG static bool log_enable = true; @@ -61,9 +61,9 @@ void logfile::end() { void logfile::printf(const char *fmt, ...) { if (fp && fmt) { char msg[256]; - va_list arglist; + std::va_list arglist; va_start(arglist, fmt); - Pvsprintf(msg, sizeof(msg), fmt, arglist); + std::vsnprintf(msg, sizeof(msg), fmt, arglist); va_end(arglist); logfile::puts(msg); diff --git a/win32/wincon.cpp b/win32/wincon.cpp index 6ebbef31..71ef2542 100644 --- a/win32/wincon.cpp +++ b/win32/wincon.cpp @@ -64,18 +64,18 @@ * $NoKeywords: $ */ +#include +#include + #include "DDAccess.h" #include "Application.h" #include "AppConsole.h" #include "TaskSystem.h" #define WIN32_LEAN_AND_MEAN -#include "pstring.h" #include -#include #include #include -#include #include @@ -102,11 +102,11 @@ int con_Char(HWND hWnd, UINT vkey); void con_Printf(const char *fmt, ...) { char buf[CON_MAX_STRINGLEN]; - va_list args; + std::va_list args; // filter out messages va_start(args, fmt); - Pvsprintf(buf, CON_MAX_STRINGLEN, fmt, args); + std::vsnprintf(buf, CON_MAX_STRINGLEN, fmt, args); int len = strlen(buf); if (len >= CON_MAX_STRINGLEN) { diff --git a/win32/winmono.cpp b/win32/winmono.cpp index 807e97ee..e6e14a52 100644 --- a/win32/winmono.cpp +++ b/win32/winmono.cpp @@ -16,19 +16,18 @@ * along with this program. If not, see . */ - #ifndef RELEASE +#include +#include + #include "Debug.h" -#include "pstring.h" #include "networking.h" #define WIN32_LEAN_AND_MEAN #include #include #include -#include -#include #include #include #include @@ -152,7 +151,7 @@ void nw_InitTCPLogging(char *ip, unsigned short port) { } void nw_TCPPrintf(int n, char *format, ...) { - va_list args; + std::va_list args; if (tcp_log_sock == INVALID_SOCKET) return; @@ -162,7 +161,7 @@ void nw_TCPPrintf(int n, char *format, ...) { return; va_start(args, format); - Pvsprintf(tcp_log_buffer, MAX_TCPLOG_LEN, format, args); + std::vsnprintf(tcp_log_buffer, MAX_TCPLOG_LEN, format, args); fd_set read_fds; timeval tv = {0, 0}; @@ -372,7 +371,7 @@ void Debug_ConsoleClose(int n) { void Debug_ConsolePrintf(int n, const char *format, ...) { static bool newline = false; char *ptr = Mono_buffer; - va_list args; + std::va_list args; if (n >= MAX_NUM_VWINDOWS) return; @@ -387,7 +386,7 @@ void Debug_ConsolePrintf(int n, const char *format, ...) { // if (!OPEN) return; va_start(args, format); - Pvsprintf(ptr, MAX_MONO_LENGTH, format, args); + std::vsnprintf(ptr, MAX_MONO_LENGTH, format, args); if (strlen(ptr) >= MAX_MONO_LENGTH) { return; @@ -414,7 +413,7 @@ void Debug_ConsolePrintf(int n, const char *format, ...) { void Debug_ConsolePrintf(int n, int row, int col, const char *format, ...) { char *ptr = Mono_buffer; int r, c; - va_list args; + std::va_list args; if (Debug_NT) return; @@ -429,7 +428,7 @@ void Debug_ConsolePrintf(int n, int row, int col, const char *format, ...) { return; va_start(args, format); - Pvsprintf(ptr, MAX_MONO_LENGTH, format, args); + std::vsnprintf(ptr, MAX_MONO_LENGTH, format, args); // if (n==MAX_NUM_WINDOWS) // OutputDebugString (Mono_buffer);