Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.
This commit is contained in:
parent
2e338c00cb
commit
3d0ee53a05
6072 changed files with 2283311 additions and 0 deletions
352
Generals/Code/Tools/Autorun/ARGS.CPP
Normal file
352
Generals/Code/Tools/Autorun/ARGS.CPP
Normal file
|
@ -0,0 +1,352 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//======================================================================================
|
||||
//
|
||||
// @@@@@ @@ @ @@@@ @@@@ @@@@ @@ @ @@@@ @@@@ @@@@@ @@@@@ @@@@ @@ @
|
||||
// @@ @ @@ @ @@ @ @@ @ @@ @ @@@ @ @@ @ @@ @ @@ @ @@ @ @@ @ @@ @
|
||||
// @@@@@ @@ @ @@ @@ @@@@@@ @@ @ @ @@@@ @@@@ @@@@@ @@@@@ @@@@@@ @@
|
||||
// @@ @ @@ @ @@ @ @@ @ @@ @ @@ @@ @@ @ @@ @ @@ @ @@ @ @@ @ @@
|
||||
// @@@@@ @@@@ @@@@ @@@@ @@ @ @@ @ @@@@ @@@@ @@ @ @@@@@ @@ @ @@
|
||||
//
|
||||
// Copyright (c) 1998, 1999 Westwood Studios -- CONFIDENTIAL
|
||||
//
|
||||
// ArgC_ArgV.cpp
|
||||
//
|
||||
//======================================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// INCLUDES
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "args.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// GLOBALS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Command_Line_Arguments *Args = NULL;
|
||||
|
||||
//*****************************************************************************
|
||||
// COMMAND_LINE_ARGUMENTS::COMMAND_LINE_ARGUMENTS -- Constructor.
|
||||
//
|
||||
// INPUT: HINSTANCE hInstance
|
||||
// LPSTR lpszCmdLine
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY:
|
||||
// 09/01/1997 ML/MG : Created.
|
||||
//=============================================================================
|
||||
|
||||
Command_Line_Arguments::Command_Line_Arguments (
|
||||
HINSTANCE current_instance_handle,
|
||||
LPTSTR windows_command_line_string )
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
// debug checks...
|
||||
//--------------------------------------------------------------------------
|
||||
assert( windows_command_line_string != NULL );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// reset all class data
|
||||
//--------------------------------------------------------------------------
|
||||
memset( ArgV, 0, sizeof( ArgV ) );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Store the program name in ArgV[ 0 ].
|
||||
//--------------------------------------------------------------------------
|
||||
GetModuleFileName( current_instance_handle, ArgV[ 0 ], MAX_ARGUMENT_LENGTH );
|
||||
|
||||
const char * ptr = windows_command_line_string;
|
||||
bool potentially_forever = true;
|
||||
|
||||
ArgC = 1;
|
||||
|
||||
while( potentially_forever ) {
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Find the next non-whitespace character in the string.
|
||||
//-----------------------------------------------------------------------
|
||||
while ( *ptr == ' ' ) {
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// If we're at the end of the string, quit.
|
||||
//-----------------------------------------------------------------------
|
||||
if ( *ptr == '\0' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Store a command-line argument.
|
||||
//-----------------------------------------------------------------------
|
||||
int i = 0;
|
||||
|
||||
if ( *ptr == '"' ) {
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Skip the opening quotation mark.
|
||||
//--------------------------------------------------------------------
|
||||
++ ptr;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Collect characters until another quotation mark is encountered.
|
||||
//--------------------------------------------------------------------
|
||||
while ( *ptr != '\0' && *ptr != '"' ) {
|
||||
if ( i < MAX_ARGUMENT_LENGTH - 1 ) {
|
||||
ArgV [ ArgC ][ i ] = *ptr;
|
||||
++ i;
|
||||
}
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Skip the closing quotation mark.
|
||||
//--------------------------------------------------------------------
|
||||
if ( *ptr == '"' ) {
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Collect characters until a whitespace character is encountered.
|
||||
//--------------------------------------------------------------------
|
||||
while ( *ptr != '\0' && *ptr != ' ' ) {
|
||||
if ( i < MAX_ARGUMENT_LENGTH - 1 ) {
|
||||
ArgV [ ArgC ][ i ] = *ptr;
|
||||
++ i;
|
||||
}
|
||||
++ ptr;
|
||||
}
|
||||
}
|
||||
|
||||
ArgV [ ArgC ][ i ] = '\0';
|
||||
++ ArgC;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// COMMAND_LINE_ARGUMENTS::COMMAND_LINE_ARGUMENTS -- Constructor.
|
||||
//
|
||||
// INPUT: HINSTANCE hInstance
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY:
|
||||
// 09/01/1997 ML/MG : Created.
|
||||
//=============================================================================
|
||||
|
||||
Command_Line_Arguments::Command_Line_Arguments ( HINSTANCE current_instance_handle )
|
||||
{
|
||||
|
||||
char * windows_command_line_string = GetCommandLine();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// debug checks...
|
||||
//--------------------------------------------------------------------------
|
||||
assert( windows_command_line_string != NULL );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// reset all class data
|
||||
//--------------------------------------------------------------------------
|
||||
memset( ArgV, 0, sizeof( ArgV ) );
|
||||
|
||||
const char * ptr = windows_command_line_string;
|
||||
bool potentially_forever = true;
|
||||
|
||||
ArgC = 1;
|
||||
|
||||
while( potentially_forever ) {
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Find the next non-whitespace character in the string.
|
||||
//-----------------------------------------------------------------------
|
||||
while ( *ptr == ' ' ) {
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// If we're at the end of the string, quit.
|
||||
//-----------------------------------------------------------------------
|
||||
if ( *ptr == '\0' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Store a command-line argument.
|
||||
//-----------------------------------------------------------------------
|
||||
int i = 0;
|
||||
|
||||
if ( *ptr == '"' ) {
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Skip the opening quotation mark.
|
||||
//--------------------------------------------------------------------
|
||||
++ ptr;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Collect characters until another quotation mark is encountered.
|
||||
//--------------------------------------------------------------------
|
||||
while ( *ptr != '\0' && *ptr != '"' ) {
|
||||
if ( i < MAX_ARGUMENT_LENGTH - 1 ) {
|
||||
ArgV [ ArgC ][ i ] = *ptr;
|
||||
++ i;
|
||||
}
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Skip the closing quotation mark.
|
||||
//--------------------------------------------------------------------
|
||||
if ( *ptr == '"' ) {
|
||||
++ ptr;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Collect characters until a whitespace character is encountered.
|
||||
//--------------------------------------------------------------------
|
||||
while ( *ptr != '\0' && *ptr != ' ' ) {
|
||||
if ( i < MAX_ARGUMENT_LENGTH - 1 ) {
|
||||
ArgV [ ArgC ][ i ] = *ptr;
|
||||
++ i;
|
||||
}
|
||||
++ ptr;
|
||||
}
|
||||
}
|
||||
|
||||
ArgV [ ArgC ][ i ] = '\0';
|
||||
++ ArgC;
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// COMMAND_LINE_ARGUMENTS::~COMMAND_LINE_ARGUMENTS -- Destructor.
|
||||
//
|
||||
// INPUT: HINSTANCE hInstance
|
||||
// LPSTR lpszCmdLine
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY:
|
||||
// 09/01/1997 ML/MG : Created.
|
||||
//=============================================================================
|
||||
|
||||
Command_Line_Arguments::~Command_Line_Arguments ( void )
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
// reset all data...
|
||||
//--------------------------------------------------------------------------
|
||||
ArgC = -1;
|
||||
memset( ArgV, 0, sizeof( ArgV ) );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// COMMAND_LINE_ARGUMENTS::GET_ARGC -- Return ArgC.
|
||||
//
|
||||
// INPUT: none.
|
||||
//
|
||||
// OUTPUT: int ArgC.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY:
|
||||
// 09/01/1997 ML/MG : Created.
|
||||
//=============================================================================
|
||||
|
||||
int Command_Line_Arguments::Get_argc ( void )
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
// debug checks - make sure we at least have the application name
|
||||
//--------------------------------------------------------------------------
|
||||
assert( ArgC >= 1 );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// return how many string parameters there are in the "argv" list
|
||||
//--------------------------------------------------------------------------
|
||||
return( ArgC );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// COMMAND_LINE_ARGUMENTS::GET_ARGV -- Return ArgV.
|
||||
//
|
||||
// INPUT: none.
|
||||
//
|
||||
// OUTPUT: int ArgV.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY:
|
||||
// 09/01/1997 ML/MG : Created.
|
||||
//=============================================================================
|
||||
|
||||
const char *Command_Line_Arguments::Get_argv ( int argument_index )
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
// debug checks - make sure we at least have the application name
|
||||
//--------------------------------------------------------------------------
|
||||
assert( argument_index >= 0 );
|
||||
assert( argument_index < MAX_COMMAND_LINE_ARGUMENTS );
|
||||
assert( argument_index < ArgC );
|
||||
assert( ArgC >= 1 );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// return
|
||||
//--------------------------------------------------------------------------
|
||||
return( ArgV[ argument_index ] );
|
||||
}
|
||||
|
||||
void Command_Line_Arguments::Set_argv( int argument_index, char *arg )
|
||||
{
|
||||
if( arg == NULL || *arg == '\0' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// debug checks - make sure we at least have the application name
|
||||
//--------------------------------------------------------------------------
|
||||
assert( argument_index >= 0 );
|
||||
assert( argument_index < MAX_COMMAND_LINE_ARGUMENTS );
|
||||
assert( argument_index < ArgC );
|
||||
assert( ArgC >= 1 );
|
||||
|
||||
if (( argument_index >= 0 ) &&
|
||||
( argument_index < MAX_COMMAND_LINE_ARGUMENTS ) &&
|
||||
( argument_index < ArgC )) {
|
||||
|
||||
strcpy( ArgV[ argument_index ], arg );
|
||||
}
|
||||
}
|
||||
|
||||
|
70
Generals/Code/Tools/Autorun/ARGS.H
Normal file
70
Generals/Code/Tools/Autorun/ARGS.H
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//================================================================================================
|
||||
//
|
||||
// @@@@@ @@ @ @@@@ @@@@ @@@@ @@ @ @@@@ @@@@ @@@@@ @@@@@ @@@@ @@ @
|
||||
// @@ @ @@ @ @@ @ @@ @ @@ @ @@@ @ @@ @ @@ @ @@ @ @@ @ @@ @ @@ @
|
||||
// @@@@@ @@ @ @@ @@ @@@@@@ @@ @ @ @@@@ @@@@ @@@@@ @@@@@ @@@@@@ @@
|
||||
// @@ @ @@ @ @@ @ @@ @ @@ @ @@ @@ @@ @ @@ @ @@ @ @@ @ @@ @ @@
|
||||
// @@@@@ @@@@ @@@@ @@@@ @@ @ @@ @ @@@@ @@@@ @@ @ @@@@@ @@ @ @@
|
||||
//
|
||||
// Copyright (c) 1998, 1999 Westwood Studios -- CONFIDENTIAL
|
||||
//
|
||||
// ArgC_ArgV.h
|
||||
//
|
||||
//================================================================================================
|
||||
|
||||
#ifndef ARGS_H
|
||||
#define ARGS_H
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// INCLUDES
|
||||
//----------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
//#include "autorun.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DEFINES
|
||||
//----------------------------------------------------------------------------
|
||||
#define MAX_COMMAND_LINE_ARGUMENTS 10
|
||||
#define MAX_ARGUMENT_LENGTH 80
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// CLASS
|
||||
//----------------------------------------------------------------------------
|
||||
class Command_Line_Arguments
|
||||
{
|
||||
public:
|
||||
Command_Line_Arguments ( HINSTANCE, LPTSTR );
|
||||
Command_Line_Arguments ( LPTSTR ) {};
|
||||
Command_Line_Arguments ( HINSTANCE );
|
||||
~Command_Line_Arguments( void );
|
||||
|
||||
const char * Get_argv( int argument_index );
|
||||
int Get_argc();
|
||||
void Set_argv( int argument_index, char*arg );
|
||||
|
||||
private:
|
||||
int ArgC;
|
||||
char ArgV[ MAX_COMMAND_LINE_ARGUMENTS ][ MAX_ARGUMENT_LENGTH ];
|
||||
};
|
||||
|
||||
extern Command_Line_Arguments *Args;
|
||||
|
||||
#endif // ARGC_ARGV_H
|
282
Generals/Code/Tools/Autorun/AUTORUN.RC
Normal file
282
Generals/Code/Tools/Autorun/AUTORUN.RC
Normal file
|
@ -0,0 +1,282 @@
|
|||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Japanese resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
|
||||
#pragma code_page(932)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "僶乕僕儑儞 %s"
|
||||
IDS_CANT_FIND_FILE "%s 偑尒偮偐傝傑偣傫偱偟偨"
|
||||
END
|
||||
|
||||
#endif // Japanese resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Korean resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
|
||||
#pragma code_page(949)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "Korean <20>oAu %s."
|
||||
IDS_CANT_FIND_FILE "%s (A№)<29>| A√A№ <20>o <20>┆A<E29486>."
|
||||
END
|
||||
|
||||
#endif // Korean resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Chinese (Taiwan) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
|
||||
#pragma code_page(950)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "Chinese ac<61>? %s!C"
|
||||
IDS_CANT_FIND_FILE "”a?<3F><>i %s!C"
|
||||
END
|
||||
|
||||
#endif // Chinese (Taiwan) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "German Version %s."
|
||||
IDS_CANT_FIND_FILE "Konnte %s nicht finden."
|
||||
END
|
||||
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
1 ICON DISCARDABLE "autorun.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cursor
|
||||
//
|
||||
|
||||
2 CURSOR DISCARDABLE "arrow.cur"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
BACKGROUND BITMAP DISCARDABLE "Autorun_BG.bmp"
|
||||
BUTTON_SEL BITMAP DISCARDABLE "ARButton_Sel.bmp"
|
||||
BUTTON_REG BITMAP DISCARDABLE "ARButton_Reg.bmp"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"..\\resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
BITMAPDIALOG DIALOG DISCARDABLE 0, 0, 186, 94
|
||||
STYLE DS_ABSALIGN | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||
WS_CAPTION | WS_SYSMENU
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WAVE
|
||||
//
|
||||
|
||||
MOUSEMOVE WAVE DISCARDABLE "mouse.wav"
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VERSIONINFO_1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
FILEFLAGSMASK 0x0L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x0L
|
||||
FILETYPE 0x0L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Westwood Studios\0"
|
||||
VALUE "FileDescription", "Westwood Autorun\0"
|
||||
VALUE "FileVersion", "1.00\0"
|
||||
VALUE "InternalName", "Autorun\0"
|
||||
VALUE "LegalCopyright", "Copyright <20> Westwood Studios 2001\0"
|
||||
VALUE "OriginalFilename", "Autorun.exe\0"
|
||||
VALUE "ProductName", "Command & Conquer Renegade\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "English Version %s."
|
||||
IDS_CANT_FIND_FILE "Could not find %s."
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// French (France) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FRENCH, SUBLANG_FRENCH
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_VERSION_STRING "French Version %s."
|
||||
IDS_CANT_FIND_FILE "Impossible de trouver %s."
|
||||
END
|
||||
|
||||
#endif // French (France) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
363
Generals/Code/Tools/Autorun/Autorun English.dsp
Normal file
363
Generals/Code/Tools/Autorun/Autorun English.dsp
Normal file
|
@ -0,0 +1,363 @@
|
|||
# Microsoft Developer Studio Project File - Name="Autorun English" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Autorun English - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Autorun English.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Autorun English.mak" CFG="Autorun English - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Autorun English - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Autorun English - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""$/Renegade Setup/Autorun", SJEEAAAA"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Autorun English - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Zp1 /W3 /GX /O2 /I "../../Libraries/Include/" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c
|
||||
# SUBTRACT CPP /Fr /YX
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /fo"Release/Autorun English.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib dxguid.lib dinput8.lib d3dx8.lib d3d8.lib wsock32.lib imm32.lib wininet.lib vfw32.lib /nologo /subsystem:windows /machine:I386 /out:".\Release\Autorun.exe"
|
||||
# SUBTRACT LINK32 /debug
|
||||
|
||||
!ELSEIF "$(CFG)" == "Autorun English - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /Zp1 /W3 /Gm /GX /ZI /Od /I "../../Libraries/Include/" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /GZ /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /fo"Debug/Autorun English.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 dxguid.lib dinput8.lib d3dx8.lib d3d8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib wsock32.lib imm32.lib wininet.lib vfw32.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Autorun English - Win32 Release"
|
||||
# Name "Autorun English - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ARGS.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ARGS.H
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\autorun.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\autorun.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CallbackHook.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CDCNTRL.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CDCNTRL.H
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DrawButton.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DrawButton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\EZGIMEX.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GameText.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GameText.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GETCD.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GetCD.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gimex.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IGR.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\IGR.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Jsupport.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\JSUPPORT.H
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\leanAndMeanAutorun.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locale.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\locale.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Locale_API.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Locale_API.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\POINT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\RECT.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TTFont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TTFont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Utils.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Utils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ViewHTML.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ViewHTML.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WinFix.CPP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WinFix.H
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wnd_file.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Wnd_File.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_File.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_file.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_FileSystem.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_FileSystem.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_RAMFile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_RAMFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_StdFile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_StdFile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_StdFileSystem.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WSYS_StdFileSystem.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resources"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\arrow.cur
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Autorun.ICO
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AUTORUN.RC
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ARButton_Reg.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ARButton_Sel.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\arrow.cur
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\autorun.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Autorun_BG.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Bullet.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License French.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License French2.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License German.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License German2.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License USA.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\License USA2.bmp"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mouse.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\English\Present.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\English\Rock-n-Roll.wav"
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
BIN
Generals/Code/Tools/Autorun/Autorun.ICO
Normal file
BIN
Generals/Code/Tools/Autorun/Autorun.ICO
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
1116
Generals/Code/Tools/Autorun/CDCNTRL.CPP
Normal file
1116
Generals/Code/Tools/Autorun/CDCNTRL.CPP
Normal file
File diff suppressed because it is too large
Load diff
156
Generals/Code/Tools/Autorun/CDCNTRL.H
Normal file
156
Generals/Code/Tools/Autorun/CDCNTRL.H
Normal file
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer *
|
||||
* *
|
||||
* $Archive:: /Renegade Setup/Autorun/CDCNTRL.H $*
|
||||
* *
|
||||
* $Author:: Maria_l $*
|
||||
* *
|
||||
* $Modtime:: 4/20/01 2:07p $*
|
||||
* *
|
||||
* $Revision:: 3 $*
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifndef _CDCNTRL
|
||||
#define _CDCNTRL
|
||||
|
||||
|
||||
//#include "always.h"
|
||||
//#include <winmin.h>
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
|
||||
class CDControlClass {
|
||||
|
||||
public:
|
||||
CDControlClass(void);
|
||||
~CDControlClass(void);
|
||||
|
||||
/*
|
||||
** Force the CD tray to open on the specified drive.
|
||||
*/
|
||||
void Force_CD_Eject(int drive);
|
||||
|
||||
/*
|
||||
** Prevent the user from ejecting the CD in the specified drive.
|
||||
*/
|
||||
bool Lock_CD_Tray(int drive);
|
||||
|
||||
/*
|
||||
** Allow the user to eject the CD in the specified drive.
|
||||
*/
|
||||
bool Unlock_CD_Tray(int drive);
|
||||
|
||||
|
||||
private:
|
||||
/*
|
||||
** NT functions.
|
||||
*/
|
||||
bool Eject_CD(char drive);
|
||||
HANDLE Open_Removable_Volume(char drive);
|
||||
bool Lock_Volume(HANDLE volume);
|
||||
bool Unlock_Volume(HANDLE volume);
|
||||
bool Dismount_Volume(HANDLE volume);
|
||||
bool Prevent_Removal_Of_Volume(HANDLE volume, bool prevent);
|
||||
bool Auto_Eject_Volume(HANDLE volume);
|
||||
bool Close_Removable_Volume(HANDLE volume);
|
||||
bool Lock_CD_Drive(char drive);
|
||||
bool Unlock_CD_Drive(char drive);
|
||||
|
||||
/*
|
||||
** Win9x functions.
|
||||
*/
|
||||
HANDLE WINAPI Open_VWin32 (void);
|
||||
bool WINAPI Close_VWin32 (HANDLE vwin32);
|
||||
bool WINAPI Unlock_Logical_Volume (HANDLE vwin32, char drive);
|
||||
bool WINAPI Lock_Logical_Volume (HANDLE vwin32, char drive, char lock_level, short permissions);
|
||||
bool Lock_Volume_95 (HANDLE vwin32, char drive);
|
||||
bool Unlock_Volume_95 (HANDLE vwin32, char drive);
|
||||
bool Auto_Eject_Volume_95 (HANDLE vwin32, char drive);
|
||||
void Eject_CD_Win95 (char drive);
|
||||
bool Lock_CD_Drive_95(char drive);
|
||||
bool Unlock_CD_Drive_95(char drive);
|
||||
|
||||
};
|
||||
|
||||
extern CDControlClass CDControl;
|
||||
|
||||
|
||||
#define LOCK_TIMEOUT 2000 // 2 Seconds
|
||||
#define LOCK_RETRIES 2 // 2 times
|
||||
|
||||
/*
|
||||
** Low level structures for Win9x.
|
||||
**
|
||||
** DeviceIoControl infrastructure
|
||||
*/
|
||||
#if !defined (VWIN32_DIOC_DOS_IOCTL)
|
||||
#define VWIN32_DIOC_DOS_IOCTL 1
|
||||
|
||||
typedef struct _DIOC_REGISTERS {
|
||||
DWORD reg_EBX;
|
||||
DWORD reg_EDX;
|
||||
DWORD reg_ECX;
|
||||
DWORD reg_EAX;
|
||||
DWORD reg_EDI;
|
||||
DWORD reg_ESI;
|
||||
DWORD reg_Flags;
|
||||
} DIOC_REGISTERS, *PDIOC_REGISTERS;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Intel x86 processor status flags
|
||||
*/
|
||||
#define CARRY_FLAG 0x0001
|
||||
|
||||
/*
|
||||
** DOS IOCTL function support
|
||||
*/
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/*
|
||||
** Parameters for locking/unlocking removable media
|
||||
*/
|
||||
typedef struct _PARAMBLOCK {
|
||||
BYTE bOperation;
|
||||
BYTE bNumLocks;
|
||||
} PARAMBLOCK, *PPARAMBLOCK;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
||||
#endif //_CDCNTRL
|
||||
|
85
Generals/Code/Tools/Autorun/CallbackHook.h
Normal file
85
Generals/Code/Tools/Autorun/CallbackHook.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/CallbackHook.h $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* Steven Clinard
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 8/14/00 7:52p $
|
||||
* $Revision: 2 $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef CALLBACKHOOK_H
|
||||
#define CALLBACKHOOK_H
|
||||
|
||||
class CallbackHook
|
||||
{
|
||||
public:
|
||||
CallbackHook()
|
||||
{}
|
||||
|
||||
virtual ~CallbackHook()
|
||||
{}
|
||||
|
||||
virtual bool DoCallback(void)
|
||||
{return false;}
|
||||
|
||||
protected:
|
||||
CallbackHook(const CallbackHook&);
|
||||
const CallbackHook& operator=(const CallbackHook&);
|
||||
};
|
||||
|
||||
|
||||
template<class T> class Callback : public CallbackHook
|
||||
{
|
||||
public:
|
||||
Callback(bool (*callback)(T), T userdata)
|
||||
: mCallback(callback),
|
||||
mUserData(userdata)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~Callback()
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool DoCallback(void)
|
||||
{
|
||||
if (mCallback != NULL)
|
||||
{
|
||||
return mCallback(mUserData);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool (*mCallback)(T);
|
||||
T mUserData;
|
||||
};
|
||||
|
||||
#endif // CALLBACKHOOK_H
|
417
Generals/Code/Tools/Autorun/DrawButton.cpp
Normal file
417
Generals/Code/Tools/Autorun/DrawButton.cpp
Normal file
|
@ -0,0 +1,417 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
******************************************************************************
|
||||
* *
|
||||
* Project Name : Autorun *
|
||||
* *
|
||||
* File Name : AUTORUN.CPP *
|
||||
* *
|
||||
* Programmers: Maria del Mar McCready Legg *
|
||||
* *
|
||||
* Start Date : September 5, 1997 *
|
||||
* *
|
||||
* Last Update : October 2, 2000 [MML] *
|
||||
* *
|
||||
*----------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* DrawButton::DrawButton *
|
||||
* DrawButton::Is_Mouse_In_Region *
|
||||
* DrawButton::Return_Bitmap *
|
||||
* DrawButton::Return_Area *
|
||||
* DrawButton::Set_Stretched_Width *
|
||||
* DrawButton::Set_Stretched_Height *
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include "autorun.h"
|
||||
#include "drawbutton.h"
|
||||
#include "locale_api.h"
|
||||
#include "wnd_file.h"
|
||||
|
||||
|
||||
|
||||
#include "leanAndMeanAutorun.h"
|
||||
|
||||
#ifndef LEAN_AND_MEAN
|
||||
///////GAMEENGINE HEADERS////////////
|
||||
#include "Common/UnicodeString.h"
|
||||
#include "Common/SubsystemInterface.h"
|
||||
#include "GameClient/GameText.h"
|
||||
#endif
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::DrawButton -- Constructor for custom "Button" type.
|
||||
//
|
||||
// This custom button is drawn by the dialog, and uses the WM_MOUSEMOVE,
|
||||
// WM_LBUTTONUP, and WM_LBUTTONDOWN to trigger actions.
|
||||
//
|
||||
// INPUT: int id -- button id handle
|
||||
// int x -- x position
|
||||
// int y -- y position
|
||||
// int w -- width of button
|
||||
// int h -- height of button
|
||||
// char *normal -- name of normal button bitmap
|
||||
// char *pressed -- name of pressed button bitmap
|
||||
// char *focus -- name of focus button bitmap
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: No keyboard/mouse/paint handling built in. Do manually.
|
||||
//
|
||||
// HISTORY:
|
||||
// 07/15/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
DrawButton::DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const char * string, TTFontClass *fontptr )
|
||||
{
|
||||
Id = id;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set default rectangle settings.
|
||||
//--------------------------------------------------------------------------
|
||||
rect.left = button_rect.left;
|
||||
rect.top = button_rect.top;
|
||||
rect.right = button_rect.left + button_rect.right;
|
||||
rect.bottom = button_rect.top + button_rect.bottom;
|
||||
|
||||
MyRect.X = button_rect.left;
|
||||
MyRect.Y = button_rect.top;
|
||||
MyRect.Width = rect.right - rect.left;
|
||||
MyRect.Height = rect.bottom - rect.top;
|
||||
|
||||
TextRect.X = button_rect.left;
|
||||
TextRect.Y = button_rect.top;
|
||||
TextRect.Width = rect.right - rect.left;
|
||||
TextRect.Height = rect.bottom - rect.top;
|
||||
|
||||
StretchedWidth = rect.right - rect.left;
|
||||
StretchedHeight = rect.bottom - rect.top;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set the string variables.
|
||||
//--------------------------------------------------------------------------
|
||||
memset( String, '\0', MAX_PATH );
|
||||
// if ( string != NULL ) {
|
||||
// wcscpy( String, Locale_GetString( string_num, String ));
|
||||
|
||||
|
||||
#ifdef LEAN_AND_MEAN
|
||||
#else
|
||||
UnicodeString tempString = TheGameText->fetch(string);
|
||||
wcscpy(String, tempString.str());
|
||||
#endif
|
||||
// }
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set the font pointer.
|
||||
//--------------------------------------------------------------------------
|
||||
MyFontPtr = NULL;
|
||||
|
||||
if ( fontptr != NULL ) {
|
||||
MyFontPtr = fontptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set Button Backgrounds.
|
||||
//--------------------------------------------------------------------------
|
||||
_tcscpy( NormalBitmap, normal );
|
||||
_tcscpy( PressedBitmap, pressed );
|
||||
_tcscpy( FocusBitmap, focus );
|
||||
|
||||
if( NormalBitmap[0] != '\0' ) {
|
||||
UseBitmaps = true; // determines how to draw button.
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Start in normal mode.
|
||||
//--------------------------------------------------------------------------
|
||||
ButtonState = NORMAL_STATE;
|
||||
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT(" rect = [%d,%d,%d,%d]"), rect.left, rect.top, rect.right, rect.bottom );
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT(" MyRect = [%d,%d,%d,%d]"), MyRect.X, MyRect.Y, MyRect.Width, MyRect.Height );
|
||||
}
|
||||
|
||||
DrawButton::DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const wchar_t *string, TTFontClass *fontptr )
|
||||
{
|
||||
Id = id;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set default rectangle settings.
|
||||
//--------------------------------------------------------------------------
|
||||
rect.left = button_rect.left;
|
||||
rect.top = button_rect.top;
|
||||
rect.right = button_rect.left + button_rect.right;
|
||||
rect.bottom = button_rect.top + button_rect.bottom;
|
||||
|
||||
MyRect.X = button_rect.left;
|
||||
MyRect.Y = button_rect.top;
|
||||
MyRect.Width = rect.right - rect.left;
|
||||
MyRect.Height = rect.bottom - rect.top;
|
||||
|
||||
TextRect.X = button_rect.left;
|
||||
TextRect.Y = button_rect.top;
|
||||
TextRect.Width = rect.right - rect.left;
|
||||
TextRect.Height = rect.bottom - rect.top;
|
||||
|
||||
StretchedWidth = rect.right - rect.left;
|
||||
StretchedHeight = rect.bottom - rect.top;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set the string variables.
|
||||
//--------------------------------------------------------------------------
|
||||
memset( String, '\0', MAX_PATH );
|
||||
if ( string != NULL ) {
|
||||
wcscpy( String, string );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set the font pointer.
|
||||
//--------------------------------------------------------------------------
|
||||
MyFontPtr = NULL;
|
||||
|
||||
if ( fontptr != NULL ) {
|
||||
MyFontPtr = fontptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Set Button Backgrounds.
|
||||
//--------------------------------------------------------------------------
|
||||
_tcscpy( NormalBitmap, normal );
|
||||
_tcscpy( PressedBitmap, pressed );
|
||||
_tcscpy( FocusBitmap, focus );
|
||||
|
||||
if( NormalBitmap[0] != '\0' ) {
|
||||
UseBitmaps = true; // determines how to draw button.
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Start in normal mode.
|
||||
//--------------------------------------------------------------------------
|
||||
ButtonState = NORMAL_STATE;
|
||||
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT(" rect = [%d,%d,%d,%d]"), rect.left, rect.top, rect.right, rect.bottom );
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT(" MyRect = [%d,%d,%d,%d]"), MyRect.X, MyRect.Y, MyRect.Width, MyRect.Height );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Draw_Text -- Check if mouse values are in button area.
|
||||
//
|
||||
// INPUT: HDC hDC -- DC to paint to.
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS:
|
||||
//
|
||||
// HISTORY:
|
||||
// 01/18/2002 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
void DrawButton::Draw_Text ( HDC hDC )
|
||||
{
|
||||
RECT outline_rect;
|
||||
Rect rect;
|
||||
|
||||
if( hDC == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Return_Area( &outline_rect );
|
||||
Return_Text_Area( &rect );
|
||||
|
||||
/*
|
||||
** This function was combining the pixel color with the background,
|
||||
** so it never looked correct.
|
||||
*/
|
||||
// SetTextColor( hDC, RGB( 0, 240, 0 ));
|
||||
// DrawFocusRect( hDC, &dst_rect );
|
||||
|
||||
if ( Get_State() == DrawButton::PRESSED_STATE ) {
|
||||
MyFontPtr->Print(
|
||||
hDC,
|
||||
String,
|
||||
rect,
|
||||
TEXT_PRESSED_COLOR,
|
||||
TEXT_PRESSED_SHADOW_COLOR,
|
||||
TPF_BUTTON,
|
||||
TPF_SHADOW );
|
||||
|
||||
} else if ( Get_State() == DrawButton::FOCUS_STATE ) {
|
||||
MyFontPtr->Print(
|
||||
hDC,
|
||||
String,
|
||||
rect,
|
||||
TEXT_FOCUSED_COLOR,
|
||||
TEXT_FOCUSED_SHADOW_COLOR,
|
||||
TPF_BUTTON,
|
||||
TPF_SHADOW );
|
||||
|
||||
} else {
|
||||
MyFontPtr->Print(
|
||||
hDC,
|
||||
String,
|
||||
rect,
|
||||
TEXT_NORMAL_COLOR,
|
||||
TEXT_NORMAL_SHADOW_COLOR,
|
||||
TPF_BUTTON,
|
||||
TPF_SHADOW );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Is_Mouse_In_Region -- Check if mouse values are in button area.
|
||||
//
|
||||
// INPUT: int mouse_x -- mouse x position
|
||||
// int mouse_y -- mouse y position
|
||||
//
|
||||
// OUTPUT: bool -- true of false.
|
||||
//
|
||||
// WARNINGS: No keyboard/mouse/paint handling built in. Do manually.
|
||||
// Note: width is shortened below to accomodate actual bitmap area.
|
||||
//
|
||||
// HISTORY:
|
||||
// 07/15/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
bool DrawButton::Is_Mouse_In_Region ( int mouse_x, int mouse_y )
|
||||
{
|
||||
if ( mouse_x < 0 || mouse_y < 0 ) {
|
||||
return( false );
|
||||
}
|
||||
|
||||
if (( mouse_x >= rect.left ) &&
|
||||
( mouse_y >= rect.top ) &&
|
||||
( mouse_x <= rect.left + StretchedWidth ) &&
|
||||
( mouse_y <= rect.top + StretchedHeight )) {
|
||||
return ( TRUE );
|
||||
}
|
||||
return ( FALSE );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Return_Bitmap
|
||||
//
|
||||
// Return name of correct bitmap based on state of button.
|
||||
//
|
||||
// INPUT: none.
|
||||
//
|
||||
// OUTPUT: char *bitmap -- name of bitmap file.
|
||||
//
|
||||
// WARNINGS: No keyboard/mouse/paint handling built in. Do manually.
|
||||
//
|
||||
// HISTORY:
|
||||
// 07/15/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
char *DrawButton::Return_Bitmap ( void )
|
||||
{
|
||||
if ( ButtonState == PRESSED_STATE ) {
|
||||
return ( PressedBitmap );
|
||||
} else if ( ButtonState == FOCUS_STATE ) {
|
||||
return ( FocusBitmap );
|
||||
} else {
|
||||
return ( NormalBitmap );
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Return_Area -- Return x, y and width and height of button.
|
||||
//
|
||||
// INPUT: RECT area -- holds the x,y,width,height information.
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: No keyboard/mouse/paint handling built in. Do manually.
|
||||
//
|
||||
// HISTORY:
|
||||
// 07/15/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
void DrawButton::Return_Area ( RECT *area )
|
||||
{
|
||||
area->left = rect.left;
|
||||
area->top = rect.top;
|
||||
area->right = rect.left + StretchedWidth;
|
||||
area->bottom = rect.top + StretchedHeight;
|
||||
}
|
||||
|
||||
void DrawButton::Return_Area ( Rect *area )
|
||||
{
|
||||
area->X = MyRect.X;
|
||||
area->Y = MyRect.Y;
|
||||
area->Width = MyRect.Width;
|
||||
area->Height = MyRect.Height;
|
||||
}
|
||||
|
||||
void DrawButton::Return_Text_Area ( Rect *area )
|
||||
{
|
||||
area->X = TextRect.X;
|
||||
area->Y = TextRect.Y;
|
||||
area->Width = TextRect.Width;
|
||||
area->Height = TextRect.Height;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Set_Stretched_Width -- Set draw width of button.
|
||||
//
|
||||
// INPUT: int value -- destination width size.
|
||||
//
|
||||
//OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY: 08/12/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
int DrawButton::Set_Stretched_Width ( int value )
|
||||
{
|
||||
int nWidth = StretchedWidth;
|
||||
|
||||
StretchedWidth = value;
|
||||
return ( nWidth );
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// DrawButton::Set_Stretched_Height -- Set draw height of button.
|
||||
//
|
||||
// INPUT: int value -- destination height size.
|
||||
//
|
||||
// OUTPUT: none.
|
||||
//
|
||||
// WARNINGS: none.
|
||||
//
|
||||
// HISTORY: 08/12/1996 MML : Created.
|
||||
//=============================================================================
|
||||
|
||||
int DrawButton::Set_Stretched_Height ( int value )
|
||||
{
|
||||
int nHeight = StretchedHeight;
|
||||
|
||||
StretchedHeight = value;
|
||||
return( nHeight );
|
||||
}
|
||||
|
||||
|
108
Generals/Code/Tools/Autorun/DrawButton.h
Normal file
108
Generals/Code/Tools/Autorun/DrawButton.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
|
||||
************************************************************************
|
||||
* *
|
||||
* Project Name : DrawButton *
|
||||
* *
|
||||
* File Name : DRAWBUTTON.H *
|
||||
* *
|
||||
* Programmer : Maria del Mar McCready Legg *
|
||||
* *
|
||||
* Start Date : May 10, 1994 *
|
||||
* *
|
||||
* Last Update : October 5, 2000 [MML] *
|
||||
*----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DRAWBUTTONS_H
|
||||
#define DRAWBUTTONS_H
|
||||
|
||||
#include <tchar.h>
|
||||
#include <stdlib.h>
|
||||
#include "ttfont.h"
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Custom "Button" Class
|
||||
//-------------------------------------------------------------------------
|
||||
class DrawButton
|
||||
{
|
||||
public:
|
||||
|
||||
enum BUTTON_STATE {
|
||||
NORMAL_STATE = 0,
|
||||
PRESSED_STATE,
|
||||
FOCUS_STATE
|
||||
};
|
||||
|
||||
DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const char *string, TTFontClass *fontptr );
|
||||
DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const wchar_t *string, TTFontClass *fontptr );
|
||||
|
||||
char *Return_Normal_Bitmap ( void ) { return NormalBitmap; };
|
||||
char *Return_Pressed_Bitmap ( void ) { return PressedBitmap; };
|
||||
char *Return_Focus_Bitmap ( void ) { return FocusBitmap; };
|
||||
char *Return_Bitmap ( void );
|
||||
|
||||
bool Draw_Bitmaps ( void ) { return( UseBitmaps ); };
|
||||
|
||||
void Draw_Text ( HDC hDC );
|
||||
|
||||
BUTTON_STATE Get_State ( void ) { return ButtonState; };
|
||||
bool Is_Mouse_In_Region ( int mouse_x, int mouse_y );
|
||||
int Return_Id ( void ) { return Id; };
|
||||
int Return_X_Pos ( void ) { return rect.left; };
|
||||
int Return_Y_Pos ( void ) { return rect.top; };
|
||||
int Return_Width ( void ) { return( rect.right - rect.left ); };
|
||||
int Return_Height ( void ) { return( rect.bottom - rect.top ); };
|
||||
int Return_Stretched_Width ( void ) { return( StretchedWidth ); };
|
||||
int Return_Stretched_Height ( void ) { return( StretchedHeight ); };
|
||||
void Return_Area ( RECT *area );
|
||||
void Return_Area ( Rect *area );
|
||||
void Return_Text_Area ( Rect *area );
|
||||
TTFontClass *Return_Font_Ptr ( void ) { return( MyFontPtr ); };
|
||||
wchar_t *Return_Text ( void ) { return( String ); };
|
||||
void Set_State ( BUTTON_STATE state ) { ButtonState = state; };
|
||||
int Set_Stretched_Width ( int );
|
||||
int Set_Stretched_Height ( int );
|
||||
|
||||
protected:
|
||||
|
||||
int Id;
|
||||
Rect MyRect;
|
||||
Rect TextRect;
|
||||
RECT rect;
|
||||
BUTTON_STATE ButtonState;
|
||||
int StretchedWidth;
|
||||
int StretchedHeight;
|
||||
bool UseBitmaps;
|
||||
TTFontClass *MyFontPtr;
|
||||
|
||||
wchar_t String[ MAX_PATH ];
|
||||
char NormalBitmap [ _MAX_FNAME ];
|
||||
char PressedBitmap[ _MAX_FNAME ];
|
||||
char FocusBitmap [ _MAX_FNAME ];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
213
Generals/Code/Tools/Autorun/EZGIMEX.cpp
Normal file
213
Generals/Code/Tools/Autorun/EZGIMEX.cpp
Normal file
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Copyright (C) Electronic Arts Canada Inc. 1994-1998. All rights reserved. */
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* ANSI Standard File and Memory Interface v1.04 */
|
||||
/* */
|
||||
/* by FrANK G. Barchard, EAC */
|
||||
/* */
|
||||
/* Code Module - May 24, 1995 */
|
||||
/* */
|
||||
/*------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Module Notes: */
|
||||
/* ------------- */
|
||||
/* This modules makes an easy basis for new Gimex low level */
|
||||
/* functions. You will need to make the following changes: */
|
||||
/* */
|
||||
/* function what to change */
|
||||
/* -------- -------------- */
|
||||
/* galloc/free put in your memory manager */
|
||||
/* LIBHANDLE.handle handle for your file system */
|
||||
/* gopen/gwopen fopen, fseek, ftell (find file size) */
|
||||
/* gclose fclose */
|
||||
/* gread fread and possibly memcpy */
|
||||
/* gwrite fwrite */
|
||||
/* gseek fseek */
|
||||
/* */
|
||||
/* The other routines should not need changing. */
|
||||
/* */
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
/* And increase stream buffer */
|
||||
/*
|
||||
setvbuf(f, NULL, _IOFBF, FILE_BUFFER_SIZE);
|
||||
*/
|
||||
|
||||
#define __NOINLINE__ 1
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "gimex.h"
|
||||
#include "wnd_file.h"
|
||||
|
||||
/* Memory Functions */
|
||||
|
||||
int galloccount=0;
|
||||
|
||||
void * GCALL galloc(long size)
|
||||
{
|
||||
++galloccount;
|
||||
return(malloc((size_t)size));
|
||||
}
|
||||
|
||||
int GCALL gfree(void *memptr)
|
||||
{
|
||||
--galloccount;
|
||||
free(memptr);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* get motorola memory */
|
||||
|
||||
unsigned long ggetm(void *src, int bytes)
|
||||
{
|
||||
unsigned char *s = (unsigned char *) src;
|
||||
unsigned long value;
|
||||
|
||||
value = 0L;
|
||||
while (bytes--)
|
||||
{
|
||||
value = (value<<8) + ((*s++));
|
||||
}
|
||||
return(value);
|
||||
}
|
||||
|
||||
/* get intel memory */
|
||||
|
||||
unsigned long ggeti(void *src, int bytes)
|
||||
{
|
||||
unsigned char *s = (unsigned char *) src;
|
||||
int i = 0;
|
||||
unsigned long value;
|
||||
|
||||
value = 0L;
|
||||
while (bytes--)
|
||||
{
|
||||
value += ((*s++)) << (i);
|
||||
i += 8;
|
||||
}
|
||||
return(value);
|
||||
}
|
||||
|
||||
/* put motorolla memory */
|
||||
|
||||
void gputm(void *dst, unsigned long data, int bytes)
|
||||
{
|
||||
unsigned char *d = (unsigned char *) dst;
|
||||
unsigned long pval;
|
||||
|
||||
data <<= (4-bytes)*8;
|
||||
while (bytes)
|
||||
{
|
||||
pval = data >> 24;
|
||||
*d++ = (unsigned char) pval;
|
||||
data <<= 8;
|
||||
--bytes;
|
||||
}
|
||||
}
|
||||
|
||||
/* put intel memory */
|
||||
|
||||
void gputi(void *dst, unsigned long data, int bytes)
|
||||
{
|
||||
unsigned char *d = (unsigned char *) dst;
|
||||
unsigned long pval;
|
||||
|
||||
while (bytes)
|
||||
{
|
||||
pval = data;
|
||||
*d++ = (unsigned char) pval;
|
||||
data >>= 8;
|
||||
--bytes;
|
||||
}
|
||||
}
|
||||
|
||||
/* File Functions */
|
||||
|
||||
GSTREAM * GCALL gopen(const char *filename)
|
||||
{
|
||||
FILE *handle;
|
||||
|
||||
Msg( __LINE__, __FILE__, "gopen:: %s.", filename );
|
||||
|
||||
handle = fopen( filename, "r+b" );
|
||||
|
||||
Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != NULL )? 1 : 0 ));
|
||||
|
||||
if ( !handle ) {
|
||||
|
||||
handle = fopen( filename, "rb" );
|
||||
|
||||
Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != NULL )? 1 : 0 ));
|
||||
}
|
||||
return((GSTREAM *) handle);
|
||||
}
|
||||
|
||||
GSTREAM * GCALL gwopen(const char *filename)
|
||||
{
|
||||
FILE *handle;
|
||||
|
||||
handle = fopen(filename,"w+b");
|
||||
if (!handle)
|
||||
handle = fopen(filename,"wb");
|
||||
|
||||
return((GSTREAM *) handle);
|
||||
}
|
||||
|
||||
int GCALL gclose(GSTREAM *g)
|
||||
{
|
||||
int ok=1;
|
||||
if (g)
|
||||
ok = !fclose((FILE*) g);
|
||||
return(ok);
|
||||
}
|
||||
|
||||
int GCALL gread(GSTREAM *g, void *buf, long size)
|
||||
{
|
||||
return(fread(buf, (size_t) 1, (size_t) size, (FILE *) g));
|
||||
}
|
||||
|
||||
int GCALL gwrite(GSTREAM *g, void *buf, long size)
|
||||
{
|
||||
return(fwrite(buf, (size_t)1, (size_t)size, (FILE *) g));
|
||||
}
|
||||
|
||||
int GCALL gseek(GSTREAM *g, long offset)
|
||||
{
|
||||
return(!fseek((FILE *) g, offset, SEEK_SET));
|
||||
}
|
||||
|
||||
long GCALL glen(GSTREAM *g)
|
||||
{
|
||||
long len;
|
||||
long oldpos = gtell(g);
|
||||
fseek((FILE *)g, 0, SEEK_END);
|
||||
len = gtell(g);
|
||||
fseek((FILE *)g, oldpos, SEEK_SET);
|
||||
return(len);
|
||||
}
|
||||
|
||||
long GCALL gtell(GSTREAM *g)
|
||||
{
|
||||
return(ftell((FILE *) g));
|
||||
}
|
||||
|
414
Generals/Code/Tools/Autorun/GETCD.CPP
Normal file
414
Generals/Code/Tools/Autorun/GETCD.CPP
Normal file
|
@ -0,0 +1,414 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
***** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *****
|
||||
****************************************************************************
|
||||
* Project Name:: Command & Conquer *
|
||||
* $Archive:: /Renegade Setup/Autorun/GETCD.CPP $Author:: Steve_t *
|
||||
* $Modtime:: 1/28/02 10:54a $Revision:: 20 *
|
||||
*--------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* GetCDClass::GetCDClass -- default constructor *
|
||||
* GetCDClass::~GetCDClass -- destructor *
|
||||
* GetCDClass::GetCDDrive -- returns the logical CD drive *
|
||||
* CD_Volume_Verification -- Check label of the CDRom. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
//#include "always.h"
|
||||
#include "getcd.h"
|
||||
//#include "timer.h"
|
||||
#include "wnd_file.h"
|
||||
//#include "missiondisk.h"
|
||||
#include "winfix.h"
|
||||
|
||||
#ifndef ROR_NOT_READY
|
||||
#define ROR_NOT_READY 21
|
||||
#endif
|
||||
|
||||
/**********************************************************************
|
||||
** This macro serves as a general way to determine the number of elements
|
||||
** within an array.
|
||||
*/
|
||||
#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0]))
|
||||
#define size_of(typ,id) sizeof(((typ*)0)->id)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Global Variables
|
||||
//-----------------------------------------------------------------------------
|
||||
#if ( MISSION_DISK )
|
||||
|
||||
static char * _CD_Volume_Label[] = {
|
||||
"Renegade Mission", // Yuri's Revenge (mission disk)
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
static char * _CD_Volume_Label[] = {
|
||||
"Renegade Game", // Red Alert 2
|
||||
"Renegade Data", // Red Alert 2
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static int _Num_Volumes = ARRAY_SIZE( _CD_Volume_Label );
|
||||
|
||||
GetCDClass CDList;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* GetCDClass -- default constructor *
|
||||
* *
|
||||
* INPUT: *
|
||||
* none *
|
||||
* OUTPUT: *
|
||||
* none *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/26/1994 SW : Created. *
|
||||
* 12/04/1995 ST : fixed for Win95 *
|
||||
*==========================================================================*/
|
||||
GetCDClass::GetCDClass( void )
|
||||
{
|
||||
char path[]={ "a:\\" };
|
||||
|
||||
CDCount = 0;
|
||||
CDIndex = 0;
|
||||
|
||||
Msg( __LINE__, __FILE__, "GetCDClass constructor\n" );
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
** Set all CD drive placeholders to empty
|
||||
*/
|
||||
for( int j = 0; j < MAX_CD_DRIVES; j++ ) {
|
||||
CDDrives[j] = NO_CD_DRIVE;
|
||||
}
|
||||
|
||||
for( char i = 'c'; i <= 'z'; i++ ) {
|
||||
|
||||
path[0] = i;
|
||||
|
||||
if ( GetDriveType( path ) == DRIVE_CDROM ) {
|
||||
CDDrives[ CDCount++ ] = (int)( i-'a' );
|
||||
Msg( __LINE__, __FILE__, "CD drive found - %c:\n", i +'A'-'a' );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
** Catch the case when there are NO CD-ROM drives available
|
||||
*/
|
||||
if ( CDCount == 0 ) {
|
||||
for ( char i = 'a'; i <= 'b'; i++ ) {
|
||||
path[0] = i;
|
||||
if ( GetDriveType( path ) == DRIVE_CDROM ) {
|
||||
CDDrives[ CDCount++ ] = (int)( i-'a' );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( CDCount == 0 ) {
|
||||
Msg( __LINE__, __FILE__, "No CD drives found\n");
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* GetCDClass -- destructor *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/26/1994 SW: Created. *
|
||||
* 12/4/95 ST: fixed for Win95 *
|
||||
*==============================================================================*/
|
||||
GetCDClass::~GetCDClass(void)
|
||||
{
|
||||
// if(cdDrive_addrp.seg)
|
||||
// DPMI_real_free(cdDrive_addrp); // free up those conventional buffers
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* GetCDClass -- Get_CD_Drive_For_This_Volume *
|
||||
* *
|
||||
* INPUT: char *volume_name *
|
||||
* *
|
||||
* OUTPUT: int *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/18/2000 MML: Created. *
|
||||
*==============================================================================*/
|
||||
|
||||
int GetCDClass::Get_CD_Drive_For_This_Volume ( char *volume_label )
|
||||
{
|
||||
char volume_name[128] = "";
|
||||
int count = 0;
|
||||
char buffer[128];
|
||||
unsigned misc_dword;
|
||||
unsigned filename_length;
|
||||
int cd_drive;
|
||||
|
||||
CDIndex = 0;
|
||||
|
||||
while( CDIndex < CDCount ) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// NOTE: A=0, B=1, C=2, D=3, etc...
|
||||
//---------------------------------------------------------------------
|
||||
cd_drive = CDDrives[ CDIndex++ ];
|
||||
wsprintf( buffer, "%c:\\", 'A' + cd_drive );
|
||||
|
||||
if ( GetVolumeInformation(
|
||||
(char const *)buffer,
|
||||
&volume_name[0],
|
||||
(unsigned long)sizeof(volume_name)-1,
|
||||
(unsigned long *)NULL,
|
||||
(unsigned long *)&filename_length,
|
||||
(unsigned long *)&misc_dword,
|
||||
(char *)NULL,
|
||||
(unsigned long)0 )) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Windows '95 appears to have a volume name limit of 11 characters.
|
||||
// I cannot find a Win32 call that will return the maximum volume name
|
||||
// length so the value '11' is hard-coded here and the assumption made
|
||||
// that all OS's have this length or better.
|
||||
//---------------------------------------------------------------------
|
||||
if( WinVersion.Is_Win95()) {
|
||||
volume_name[11] = '\0';
|
||||
}
|
||||
|
||||
if ( !_stricmp( volume_label, volume_name )) {
|
||||
return( cd_drive );
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
#if _DEBUG
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
Msg( __LINE__, __FILE__, (LPTSTR)lpMsgBuf );
|
||||
LocalFree( lpMsgBuf );
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
return( Get_First_CD_Drive());
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* GetCDClass -- Get_Volume_Label *
|
||||
* *
|
||||
* INPUT: int index *
|
||||
* *
|
||||
* OUTPUT: char * *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/31/2000 MML: Created. * Happy Halloween! * *
|
||||
*==============================================================================*/
|
||||
|
||||
char * GetCDClass::Get_Volume_Label ( int index )
|
||||
{
|
||||
if( index >= 0 && index < _Num_Volumes ) {
|
||||
return( _CD_Volume_Label[ index ]);
|
||||
}
|
||||
return( _CD_Volume_Label[0]);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* GetCDClass -- Get_Volume_For_This_CD_Drive *
|
||||
* *
|
||||
* INPUT: char *volume_name *
|
||||
* char *path *
|
||||
* *
|
||||
* OUTPUT: int *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/31/2000 MML: Created. * Happy Halloween! * *
|
||||
*==============================================================================*/
|
||||
|
||||
char *GetCDClass::Get_Volume_For_This_CD_Drive ( char *path, char *volume_name )
|
||||
{
|
||||
char buffer[128];
|
||||
unsigned misc_dword;
|
||||
unsigned filename_length;
|
||||
static char volume_label[ MAX_PATH ] = ""; // [OYO] add static
|
||||
|
||||
if ( path == NULL || volume_name == NULL ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
memset( volume_name, '\0', sizeof( volume_name ));
|
||||
wsprintf( buffer, "%c:\\", path[0] );
|
||||
|
||||
if ( GetVolumeInformation(
|
||||
(char const *)buffer,
|
||||
&volume_label[0],
|
||||
(unsigned long)sizeof(volume_label)-1,
|
||||
(unsigned long *)NULL,
|
||||
(unsigned long *)&filename_length,
|
||||
(unsigned long *)&misc_dword,
|
||||
(char *)NULL,
|
||||
(unsigned long)0 )) {
|
||||
|
||||
strcpy( volume_name, volume_label );
|
||||
|
||||
} else {
|
||||
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
Msg( __LINE__, __FILE__, (LPTSTR)lpMsgBuf );
|
||||
LocalFree( lpMsgBuf );
|
||||
|
||||
strcpy( volume_name, _CD_Volume_Label[0] );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Windows '95 appears to have a volume name limit of 11 characters.
|
||||
// I cannot find a Win32 call that will return the maximum volume name
|
||||
// length so the value '11' is hard-coded here and the assumption made
|
||||
// that all OS's have this length or better.
|
||||
//-------------------------------------------------------------------------
|
||||
bool winversion = WinVersion.Is_Win95();
|
||||
|
||||
if( winversion ) {
|
||||
volume_name[11] = '\0';
|
||||
}
|
||||
|
||||
return( volume_name );
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* CD_VOLUME_VERIFICATION -- Check volume label of the CD in the given drive. *
|
||||
* *
|
||||
* INPUT: int drive_number *
|
||||
* char *lable *
|
||||
* *
|
||||
* OUTPUT: TRUE/FALSE *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 01/11/99 4:20PM MML : Created *
|
||||
*==============================================================================*/
|
||||
|
||||
bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_find )
|
||||
{
|
||||
char volume_name[128] = "";
|
||||
int count = 0;
|
||||
char buffer[128];
|
||||
unsigned misc_dword;
|
||||
unsigned filename_length;
|
||||
|
||||
/***************************************************************************
|
||||
** Get the volume label. If we get a 'not ready' error then retry for the
|
||||
** timeout period.
|
||||
*/
|
||||
for (;;) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// NOTE: A=0, B=1, C=2, D=3, etc...
|
||||
//---------------------------------------------------------------------
|
||||
wsprintf( buffer, "%c:\\", 'A' + cd_drive );
|
||||
|
||||
if ( GetVolumeInformation(
|
||||
(char const *)buffer,
|
||||
&volume_name[0],
|
||||
(unsigned long)sizeof(volume_name)-1,
|
||||
(unsigned long *)NULL,
|
||||
(unsigned long *)&filename_length,
|
||||
(unsigned long *)&misc_dword,
|
||||
(char *)NULL,
|
||||
(unsigned long)0 )) {
|
||||
|
||||
/******************************************************************
|
||||
** Match the volume label to the list of known volume labels.
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Windows '95 appears to have a volume name limit of 11 characters.
|
||||
// I cannot find a Win32 call that will return the maximum volume name
|
||||
// length so the value '11' is hard-coded here and the assumption made
|
||||
// that all OS's have this length or better.
|
||||
//---------------------------------------------------------------------
|
||||
if( WinVersion.Is_Win95()) {
|
||||
volume_name[11] = '\0';
|
||||
}
|
||||
|
||||
if ( volume_label != NULL ) {
|
||||
strncpy( volume_label, volume_name, 128 );
|
||||
}
|
||||
|
||||
if ( !_stricmp( volume_to_find, volume_name )) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( !count ) {
|
||||
count++;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/*********************************************************************
|
||||
** Failed to get the volume label on a known CD drive. If this is a
|
||||
** CD changer it may require time to swap the disks so don't return
|
||||
** immediately if the error is ROR_NOT_READY
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ==================================================================== */
|
||||
|
1152
Generals/Code/Tools/Autorun/GameText.cpp
Normal file
1152
Generals/Code/Tools/Autorun/GameText.cpp
Normal file
File diff suppressed because it is too large
Load diff
82
Generals/Code/Tools/Autorun/GameText.h
Normal file
82
Generals/Code/Tools/Autorun/GameText.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright (C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: RTS 3
|
||||
//
|
||||
// File name: GameClient/GameText.h
|
||||
//
|
||||
// Created: 11/07/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __GAMECLIENT_GAMETEXT_H_
|
||||
#define __GAMECLIENT_GAMETEXT_H_
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// GameTextInterface
|
||||
//===============================
|
||||
/** Game text interface object for localised text.
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class GameTextInterface
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~GameTextInterface() {};
|
||||
|
||||
virtual void init( void ) = 0; ///< Initlaizes the text system
|
||||
virtual const wchar_t * fetch( const char *label ) = 0; ///< Returns the associated labeled unicode text
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern GameTextInterface *TheGameText;
|
||||
extern GameTextInterface* CreateGameTextInterface( void );
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // __GAMECLIENT_GAMETEXT_H_
|
323
Generals/Code/Tools/Autorun/GetCD.h
Normal file
323
Generals/Code/Tools/Autorun/GetCD.h
Normal file
|
@ -0,0 +1,323 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ****
|
||||
************************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer *
|
||||
* *
|
||||
* $Archive:: /Renegade Setup/Autorun/GetCD.h $Author:: Denzil_l *
|
||||
* $Modtime:: 1/08/02 3:38p $Revision:: 20 *
|
||||
* *
|
||||
*----------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef GETCD_H
|
||||
#define GETCD_H
|
||||
|
||||
|
||||
extern char * _CD_Volume_Label[];
|
||||
extern int _Num_Volumes;
|
||||
|
||||
|
||||
|
||||
#ifdef NOT_FOR_WIN95
|
||||
|
||||
/* ==================================================================== */
|
||||
/* Defines */
|
||||
/* ==================================================================== */
|
||||
#define CHLEFT 0
|
||||
#define CHRIGHT 1
|
||||
#define CHBOTH 2
|
||||
#define AUDIO_START_MIN 1
|
||||
#define AUDIO_START_SEC 44
|
||||
|
||||
struct SEGSEL {
|
||||
unsigned short seg ;
|
||||
unsigned short sel ;
|
||||
};
|
||||
|
||||
extern "C" int DPMI_real_alloc ( UINT , SEGSEL * , USHORT * ) ;
|
||||
extern "C" int DPMI_real_free ( SEGSEL ) ;
|
||||
extern "C" void DPMI_real_intr ( int , union REGS * , struct SREGS * );
|
||||
extern "C" void DPMI_real_call ( void * funct , union REGS * , struct SREGS * );
|
||||
|
||||
/* ==================================================================== */
|
||||
/* Data structures */
|
||||
/* ==================================================================== */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Audio Track Info request block
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma pack(push, 1)
|
||||
struct TinfoType {
|
||||
UBYTE Length;
|
||||
UBYTE SubCd;
|
||||
UBYTE Command;
|
||||
UWORD Status;
|
||||
UBYTE Rsvd[8];
|
||||
UBYTE MDescr;
|
||||
|
||||
UWORD TrnsAdOff;
|
||||
UWORD TrnsAdSeg;
|
||||
|
||||
UWORD CntTrns;
|
||||
UWORD StSect;
|
||||
|
||||
UWORD VolIDOff;
|
||||
UWORD VolIDSeg;
|
||||
|
||||
UBYTE TrInfo;
|
||||
UBYTE Track;
|
||||
ULONG Start;
|
||||
UBYTE TrCtrl;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Audio Track Status Control Block
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma pack(push, 1)
|
||||
struct StatType {
|
||||
UBYTE Length;
|
||||
UBYTE SubCd;
|
||||
UBYTE Command;
|
||||
UWORD Status;
|
||||
UBYTE Rsvd[8];
|
||||
UBYTE MDescr;
|
||||
|
||||
UWORD TrnsAdOff;
|
||||
UWORD TrnsAdSeg;
|
||||
|
||||
UWORD CntTrns;
|
||||
UWORD StSect;
|
||||
|
||||
UWORD VolIDOff;
|
||||
UWORD VolIDSeg;
|
||||
|
||||
UBYTE StatInfo;
|
||||
UWORD Stat;
|
||||
ULONG Start;
|
||||
ULONG End;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Audio Track Volume control block
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma pack(push, 1)
|
||||
struct VolmType {
|
||||
UBYTE Length;
|
||||
UBYTE SubCd;
|
||||
UBYTE Command;
|
||||
UWORD Status;
|
||||
UBYTE Rsvd[8];
|
||||
UBYTE MDescr;
|
||||
|
||||
UWORD TrnsAdOff;
|
||||
UWORD TrnsAdSeg;
|
||||
|
||||
UWORD CntTrns;
|
||||
UWORD StSect;
|
||||
|
||||
UWORD VolIDOff;
|
||||
UWORD VolIDSeg;
|
||||
|
||||
UBYTE TrInfo;
|
||||
UBYTE In0;
|
||||
UBYTE Vol0;
|
||||
UBYTE In1;
|
||||
UBYTE Vol1;
|
||||
UBYTE In2;
|
||||
UBYTE Vol2;
|
||||
UBYTE In3;
|
||||
UBYTE Vol3;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Audio Track Play request block
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma pack(push, 1)
|
||||
struct PlayType {
|
||||
UBYTE Length;
|
||||
UBYTE SubCd;
|
||||
UBYTE Command;
|
||||
UWORD Status;
|
||||
UBYTE Rsvd[8];
|
||||
UBYTE AddrMd;
|
||||
ULONG Start;
|
||||
ULONG CntSect;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Audio Track Stop request block
|
||||
//-----------------------------------------------------------------------------
|
||||
#pragma pack(push, 1)
|
||||
struct StopType {
|
||||
UBYTE Length;
|
||||
UBYTE SubCd;
|
||||
UBYTE Command;
|
||||
UWORD Status;
|
||||
UBYTE Rsvd[8];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //NOT_FOR_WIN95
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* GetCDClass -- object which will return logical CD drive *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/04/1994 SW : Created. *
|
||||
*==========================================================================*/
|
||||
|
||||
#define MAX_CD_DRIVES 26
|
||||
#define NO_CD_DRIVE -1
|
||||
|
||||
class GetCDClass
|
||||
{
|
||||
public:
|
||||
GetCDClass ( void ); // This is the default constructor
|
||||
~GetCDClass ( void ); // This is the destructor
|
||||
|
||||
inline int Get_First_CD_Drive ( void );
|
||||
inline int Get_Next_CD_Drive ( void );
|
||||
inline int Get_Number_Of_Drives ( void ) { return( CDCount ); };
|
||||
inline int Get_Index ( void ) { return( CDIndex ); };
|
||||
inline void Reset_Index ( void ) { CDIndex = 0; };
|
||||
|
||||
int Get_CD_Drive_For_This_Volume ( char *volume_name );
|
||||
char * Get_Volume_For_This_CD_Drive ( char *path, char *volume_name );
|
||||
char * Get_Volume_Label ( int index );
|
||||
|
||||
protected:
|
||||
|
||||
int CDDrives[ MAX_CD_DRIVES ]; //Array containing CD drive letters
|
||||
int CDCount; //Number of available CD drives
|
||||
int CDIndex; //Index of current location
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* GCDC::Get_First_CD_Drive -- return the number of the first CD drive *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: logical drive number *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 05/26/1994 SW : Created. *
|
||||
* 12/4/95 ST : fixed for Win95 *
|
||||
*==========================================================================*/
|
||||
|
||||
inline int GetCDClass::Get_First_CD_Drive(void)
|
||||
{
|
||||
CDIndex = 0;
|
||||
return (Get_Next_CD_Drive());
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* GCDC::Get_Next_CD_Drive -- return the logical drive number of the next CD drive *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Logical drive number of a cd drive or -1 if none *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 5/21/96 3:50PM ST : Created *
|
||||
*==================================================================================*/
|
||||
|
||||
inline int GetCDClass::Get_Next_CD_Drive(void)
|
||||
{
|
||||
if (CDCount){
|
||||
if (CDIndex >= CDCount) {
|
||||
CDIndex = 0;
|
||||
}
|
||||
return (CDDrives[CDIndex++]);
|
||||
} else {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* RedBookClass -- adds red book functionality *
|
||||
* *
|
||||
* this class inherits from GetCDClass and adds red book play functionality *
|
||||
* *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/04/1994 SW : Created. *
|
||||
*==================================================================================*/
|
||||
|
||||
#ifdef NOT_FOR_WIN95
|
||||
class RedBookClass : public GetCDClass
|
||||
{
|
||||
public:
|
||||
|
||||
RedBookClass(void); // This is the default constructor
|
||||
~RedBookClass(void); // This is the destructor
|
||||
ULONG RedToHS(ULONG i);
|
||||
ULONG MSFtoRed(UBYTE m, UBYTE s, UBYTE f);
|
||||
void FullCDVolume(UBYTE chan);
|
||||
void PlayTrack(UWORD track);
|
||||
void Play_CD_MSL(UWORD min_sec, UWORD len);
|
||||
void PlayMSF(UBYTE startM, UBYTE startS, UBYTE startF,
|
||||
UBYTE endM, UBYTE endS, UBYTE endF, UBYTE chan);
|
||||
UWORD CheckCDMusic(void);
|
||||
void StopCDMusic(void);
|
||||
|
||||
private:
|
||||
|
||||
SEGSEL Tinfo_addrp;
|
||||
SEGSEL Stat_addrp;
|
||||
SEGSEL Stop_addrp;
|
||||
SEGSEL Volm_addrp;
|
||||
SEGSEL Play_addrp;
|
||||
|
||||
StopType Stop;
|
||||
PlayType Play;
|
||||
VolmType Volm;
|
||||
StatType Stat;
|
||||
TinfoType Tinfo;
|
||||
};
|
||||
|
||||
#endif //NOT_FOR_WIN95
|
||||
|
||||
/***************************** End of Playcd.h ****************************/
|
||||
|
||||
extern GetCDClass CDList;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_find );
|
||||
|
||||
|
||||
#endif // PLAYCD_H
|
181
Generals/Code/Tools/Autorun/IGR.cpp
Normal file
181
Generals/Code/Tools/Autorun/IGR.cpp
Normal file
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//
|
||||
// IGR.cpp - A class used to access the IGR registry settings.
|
||||
//
|
||||
// JeffB 7/5/00
|
||||
//
|
||||
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <winreg.h>
|
||||
//#include "always.h"
|
||||
#include "IGR.h"
|
||||
|
||||
|
||||
IGROptionsClass *OnlineOptions = NULL;
|
||||
|
||||
|
||||
/*********************************************************************************************
|
||||
* IGROptions::Init -- Class initializer. Reads from the registry *
|
||||
* *
|
||||
* INPUT: None *
|
||||
* *
|
||||
* OUTPUT: bool; Did we read everything OK? *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/05/00 JeffB: Initial coding *
|
||||
*===========================================================================================*/
|
||||
bool IGROptionsClass::Init( void )
|
||||
{
|
||||
int size;
|
||||
int returnValue;
|
||||
HKEY handle;
|
||||
char key[128];
|
||||
unsigned long type;
|
||||
|
||||
valid = false;
|
||||
|
||||
// Load the options from the registry
|
||||
size = sizeof( int );
|
||||
|
||||
// Setup the key
|
||||
strcpy( key, WOLAPI_REG_KEY_BOTTOM );
|
||||
|
||||
// Get a handle to the WOLAPI entry
|
||||
if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &handle ) == ERROR_SUCCESS ) {
|
||||
|
||||
// If successful, get the options
|
||||
IGROptionsType ReadOptions = 0;
|
||||
|
||||
returnValue = RegQueryValueEx(handle, WOLAPI_REG_KEY_OPTIONS, NULL,
|
||||
(unsigned long *) &type, (unsigned char *) &ReadOptions, (unsigned long *)&size);
|
||||
|
||||
if (returnValue == ERROR_SUCCESS) {
|
||||
|
||||
// If successful, and we got a DWORD, store options and set the valid flage
|
||||
if (type == REG_DWORD) {
|
||||
options = ReadOptions;
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up
|
||||
RegCloseKey( handle );
|
||||
}
|
||||
return ( valid );
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* IGROptions::Is_Auto_Login_Allowed -- Set the passed options in the registry *
|
||||
* *
|
||||
* INPUT: None *
|
||||
* *
|
||||
* OUTPUT: bool; Is the option set *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/05/00 JeffB: Initial coding *
|
||||
*=============================================================================================*/
|
||||
bool IGROptionsClass::Is_Auto_Login_Allowed( void )
|
||||
{
|
||||
return(( options & IGR_NO_AUTO_LOGIN ) == 0 );
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* IGROptions::Is_Storing_Nicks_Allowed -- Set the passed options in the registry *
|
||||
* *
|
||||
* INPUT: None *
|
||||
* *
|
||||
* OUTPUT: bool; Is the option set *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/05/00 JeffB: Initial coding *
|
||||
*=============================================================================================*/
|
||||
bool IGROptionsClass::Is_Storing_Nicks_Allowed( void )
|
||||
{
|
||||
return(( options & IGR_NEVER_STORE_NICKS ) == 0 );
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* IGROptions::Is_Running_Reg_App_Allowed -- Set the passed options in the registry *
|
||||
* *
|
||||
* INPUT: None *
|
||||
* *
|
||||
* OUTPUT: bool; Is the option set *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/05/00 JeffB: Initial coding *
|
||||
*=============================================================================================*/
|
||||
bool IGROptionsClass::Is_Running_Reg_App_Allowed( void )
|
||||
{
|
||||
return(( options & IGR_NEVER_RUN_REG_APP ) == 0 );
|
||||
}
|
||||
|
||||
/*********************************************************************************************
|
||||
* IGROptions::Set_Options -- Set the passed options in the registry *
|
||||
* *
|
||||
* INPUT: Options to set *
|
||||
* *
|
||||
* OUTPUT: bool; Did we set the options successfully *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 07/05/00 JeffB: Initial coding *
|
||||
*===========================================================================================*/
|
||||
bool IGROptionsClass::Set_Options( IGROptionsType options )
|
||||
{
|
||||
bool ReturnValue = false;
|
||||
HKEY handle;
|
||||
int disp;
|
||||
char key[ 128 ];
|
||||
|
||||
// We don't care if it's valid, we'll MAKE it valid.
|
||||
strcpy( key, WOLAPI_REG_KEY_BOTTOM );
|
||||
|
||||
// Do they have the WOLAPI key?
|
||||
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &handle ) != ERROR_SUCCESS ) {
|
||||
|
||||
// If not, make the WOLAPI key
|
||||
if( RegCreateKeyEx( HKEY_LOCAL_MACHINE, key, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
|
||||
NULL, &handle, (unsigned long *)&disp ) != ERROR_SUCCESS )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( RegSetValueEx( handle, WOLAPI_REG_KEY_OPTIONS, 0, REG_DWORD, (unsigned char *)&options, sizeof(int))
|
||||
== ERROR_SUCCESS ) {
|
||||
ReturnValue = true;
|
||||
}
|
||||
RegCloseKey( handle );
|
||||
|
||||
// Reinit the class to make sure we have these settings for later queries.
|
||||
Init();
|
||||
|
||||
assert( valid == TRUE );
|
||||
|
||||
return ReturnValue;
|
||||
}
|
75
Generals/Code/Tools/Autorun/IGR.h
Normal file
75
Generals/Code/Tools/Autorun/IGR.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//
|
||||
// IGR.h - A class used to access the IGR registry settings.
|
||||
//
|
||||
// JeffB 7/5/00
|
||||
//
|
||||
|
||||
//
|
||||
// Registry Path
|
||||
//
|
||||
#define WOLAPI_REG_KEY_TOP "HKEY_LOCAL_MACHINE"
|
||||
#define WOLAPI_REG_KEY_WOLAPI "SOFTWARE\\Westwood\\WOLAPI"
|
||||
#define WOLAPI_REG_KEY_BOTTOM WOLAPI_REG_KEY_WOLAPI "\\"
|
||||
#define WOLAPI_REG_KEY_OPTIONS "Options"
|
||||
#define WOLAPI_REG_KEY WOLAPI_REG_KEY_TOP "\\" WOLAPI_REG_KEY_BOTTOM
|
||||
#define WOLAPI_KEY "WOLAPI"
|
||||
|
||||
//
|
||||
// Option Bits for Options key
|
||||
//
|
||||
#define IGR_NO_AUTO_LOGIN 0x01
|
||||
#define IGR_NEVER_STORE_NICKS 0x02
|
||||
#define IGR_NEVER_RUN_REG_APP 0x04
|
||||
#define IGR_ALL IGR_NO_AUTO_LOGIN | IGR_NEVER_STORE_NICKS | IGR_NEVER_RUN_REG_APP
|
||||
#define IGR_NONE 0x00
|
||||
|
||||
typedef unsigned int IGROptionsType;
|
||||
|
||||
class IGROptionsClass
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
IGROptionsClass( void ) : valid( false ), options( 0 ) {};
|
||||
|
||||
// Destructor
|
||||
~IGROptionsClass( void ) {};
|
||||
|
||||
// Initialize. Read value(s) from registry
|
||||
bool Init( void );
|
||||
|
||||
// Check various options
|
||||
bool Is_Auto_Login_Allowed( void );
|
||||
bool Is_Storing_Nicks_Allowed( void );
|
||||
bool Is_Running_Reg_App_Allowed( void );
|
||||
|
||||
// Set various options
|
||||
bool Set_Options( IGROptionsType options );
|
||||
|
||||
private:
|
||||
|
||||
// Private options
|
||||
IGROptionsType options;
|
||||
|
||||
// Is the data valid?
|
||||
bool valid;
|
||||
};
|
||||
|
||||
extern IGROptionsClass *OnlineOptions;
|
21
Generals/Code/Tools/Autorun/JSUPPORT.H
Normal file
21
Generals/Code/Tools/Autorun/JSUPPORT.H
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// JSUPPORT.H
|
||||
// DBCS Support Header
|
||||
extern int nGetWord( char *,int );
|
158
Generals/Code/Tools/Autorun/Jsupport.cpp
Normal file
158
Generals/Code/Tools/Autorun/Jsupport.cpp
Normal file
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// JSUPPORT.CPP
|
||||
// DBCS Support Codes
|
||||
|
||||
#include <windows.h>
|
||||
#include "jsupport.h"
|
||||
|
||||
// 前置禁則文字
|
||||
// Can't set these characters on top of line
|
||||
static BOOL IsDBCSInvalidAtTop(unsigned int c)
|
||||
{
|
||||
static BYTE * dtbl = (BYTE *)"¢°’”‰′″℃、。々〉》」』】〕ぁぃぅぇぉっゃゅょゎ゛゜ゝゞァィゥェォッャュョヮヵヶ・ーヽヾ!%),.:;?]}";
|
||||
static BYTE * stbl = (BYTE *)"!%),.:;?]}。」、・゙゚";
|
||||
|
||||
if(c<0x100)
|
||||
{
|
||||
if(strchr((char *)stbl,(char)c))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE c1,c2,*p;
|
||||
c1 = (BYTE)(c >> 8);
|
||||
c2 = (BYTE)(c & 0xff);
|
||||
p = dtbl;
|
||||
while(*p)
|
||||
{
|
||||
if((*p==c1)&&(*(p+1)==c2))
|
||||
return TRUE;
|
||||
p+=2;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// 後置禁則文字
|
||||
// Can't set these characters on end of line
|
||||
static BOOL IsDBCSInvalidAtEnd( unsigned int c )
|
||||
{
|
||||
static BYTE * dtbl = (BYTE *)"‘“〈《「『【〔([{$£¥";
|
||||
static BYTE * stbl = (BYTE *)"「({[";
|
||||
|
||||
if(c<0x100)
|
||||
{
|
||||
if(strchr((char *)stbl,(char)c))
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE c1,c2,*p;
|
||||
c1 = (BYTE)(c >> 8);
|
||||
c2 = (BYTE)(c & 0xff);
|
||||
p = dtbl;
|
||||
while(*p)
|
||||
{
|
||||
if((*p==c1)&&(*(p+1)==c2))
|
||||
return TRUE;
|
||||
p+=2;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int nGetWord( char *string, int fdbcs )
|
||||
{
|
||||
BOOL bCiae0, bCiat1, bDbcs0, bDbcs1;
|
||||
BYTE *p = (BYTE *)string;
|
||||
UINT c0, c1, c;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// If no string was passed in, exit.
|
||||
//--------------------------------------------------------------------------
|
||||
if( !p || !( c0 = *p++ )) {
|
||||
// if(( p == NULL ) || ( *p == '\0' )) {
|
||||
return 0;
|
||||
}
|
||||
// c0 = *p;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// If we are NOT a double-byte language, then just parse first word.
|
||||
//--------------------------------------------------------------------------
|
||||
if( !fdbcs ) {
|
||||
|
||||
int n = 0;
|
||||
|
||||
while( *p >' ' ) {
|
||||
n++;
|
||||
p++;
|
||||
}
|
||||
|
||||
if( *p ) {
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// If we are a double-byte language...
|
||||
//--------------------------------------------------------------------------
|
||||
bDbcs0 = IsDBCSLeadByte( c0 ) && *p;
|
||||
|
||||
if( bDbcs0 ) {
|
||||
c0 = ( c0 << 8 ) | *p++;
|
||||
}
|
||||
|
||||
bCiae0 = IsDBCSInvalidAtEnd( c0 );
|
||||
|
||||
while( c1 = *p ) {
|
||||
|
||||
bDbcs1 = ( IsDBCSLeadByte( c1 ) && ( c = *( p + 1 )));
|
||||
if( bDbcs1 ) {
|
||||
c1 = ( c1<<8 ) | c;
|
||||
}
|
||||
|
||||
if(( bDbcs0 || bDbcs1 ) && !( bDbcs0 && bDbcs1 )) { // XOR
|
||||
break;
|
||||
}
|
||||
|
||||
if( bDbcs1 ) {
|
||||
|
||||
bCiat1 = IsDBCSInvalidAtTop( c1 );
|
||||
|
||||
if( !( bCiae0 || bCiat1 )) {
|
||||
break;
|
||||
}
|
||||
bCiae0 = IsDBCSInvalidAtEnd( c1 );
|
||||
p+=2;
|
||||
|
||||
} else {
|
||||
|
||||
if( c0<=' ' ) {
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
||||
bDbcs0 = bDbcs1;
|
||||
c0 = c1;
|
||||
}
|
||||
return( p - (BYTE *)string );
|
||||
}
|
419
Generals/Code/Tools/Autorun/Locale_API.cpp
Normal file
419
Generals/Code/Tools/Autorun/Locale_API.cpp
Normal file
|
@ -0,0 +1,419 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
* C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S *
|
||||
******************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/Locale_API.cpp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 1/22/02 5:41p $
|
||||
* $Revision: 12 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "locale.h"
|
||||
#include "locale_api.h"
|
||||
#include "utils.h"
|
||||
#include "wnd_file.h"
|
||||
//#include "resources.h"
|
||||
|
||||
#include "GameText.h"
|
||||
|
||||
#define MISSING_STRING_HINTS_MAX (20)
|
||||
|
||||
wchar_t *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] =
|
||||
{
|
||||
{ L"0 MissingInstall" },
|
||||
{ L"1 MissingExplore" },
|
||||
{ L"2 MissingPreviews" },
|
||||
{ L"3 MissingCancel" },
|
||||
{ L"4 MissingAutoRunTitle" },
|
||||
{ L"5 MissingNoExplorer" },
|
||||
{ L"6 MissingWinVersionText" },
|
||||
{ L"7 MissingWinVersionTitle" },
|
||||
{ L"8 MissingCantFind" },
|
||||
{ L"9 MissingUninstall" },
|
||||
{ L"10 MissingWebsite" },
|
||||
{ L"11 MissingCheckForUpdates" },
|
||||
{ L"12 MissingWorldBuilder" },
|
||||
{ L"13 MissingPlay" },
|
||||
{ L"14 MissingGameTitle" },
|
||||
{ L"15 MissingFullGameTitle" },
|
||||
{ L"16 MissingRegistryKey" },
|
||||
{ L"17 MissingMainWindow" },
|
||||
{ L"18 MissingThing" },
|
||||
{ L"19 UNKNOWN MESSAGE" }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* DEFINES */
|
||||
/****************************************************************************/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// NOTE: if USE_MULTI_FILE_FORMAT is "true", then a .lOC file must be in
|
||||
// the same directory as this file.
|
||||
//----------------------------------------------------------------------------
|
||||
#define USE_MULTI_FILE_FORMAT FALSE
|
||||
|
||||
#define LANGUAGE_IS_DBCS(l) (((l)==IDL_JAPANESE)||((l)==IDL_KOREAN)||((l)==IDL_CHINESE)) // [OYO]
|
||||
#define CODEPAGE_IS_DBCS(C) ((C==932)||(C==949)||(C==950)) // [OYO]
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* GLOBAL VARIABLES */
|
||||
/****************************************************************************/
|
||||
char LanguageFile[ _MAX_PATH ];
|
||||
void * LocaleFile = NULL;
|
||||
int CodePage = GetACP();
|
||||
int LanguageID = 0;
|
||||
int PrimaryLanguage = LANG_NEUTRAL;
|
||||
int SubLanguage = SUBLANG_DEFAULT;
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* LOCALE API */
|
||||
/****************************************************************************/
|
||||
wchar_t * Remove_Quotes_Around_String ( wchar_t *old_string );
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// These are wrapper functions around the LOCALE_ functions. I made these to
|
||||
// make using the single vs. multi language files more transparent to the program.
|
||||
//=============================================================================
|
||||
|
||||
bool Locale_Use_Multi_Language_Files ( void )
|
||||
{
|
||||
#if( USE_MULTI_FILE_FORMAT )
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* initialization */
|
||||
/****************************************************************************/
|
||||
|
||||
int Locale_Init ( int language, char *file )
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
TheGameText = CreateGameTextInterface();
|
||||
TheGameText->init();
|
||||
|
||||
/*
|
||||
//-------------------------------------------------------------------------
|
||||
// Check for valid language range.
|
||||
//-------------------------------------------------------------------------
|
||||
if( language < 0 || language >= LANG_NUM ) {
|
||||
language = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Check for a file passed in.
|
||||
//-------------------------------------------------------------------------
|
||||
if( file == NULL || file[0] == '/0' ) {
|
||||
return 0;
|
||||
}
|
||||
strcpy( LanguageFile, file );
|
||||
LanguageID = language;
|
||||
|
||||
Msg( __LINE__, __FILE__, "LanguageID = %d", LanguageID );
|
||||
Msg( __LINE__, __FILE__, "CodePage = %d.", CodePage );
|
||||
Msg( __LINE__, __FILE__, "LanguageFile = %s.", LanguageFile );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Initialize the lx object.
|
||||
//-------------------------------------------------------------------------
|
||||
LOCALE_init();
|
||||
|
||||
#if( USE_MULTI_FILE_FORMAT )
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Set bank to use and load the appropriate table.
|
||||
//---------------------------------------------------------------------
|
||||
LOCALE_setbank(0);
|
||||
result = LOCALE_loadtable( LanguageFile, LanguageID );
|
||||
|
||||
#else
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Create a file buffer that holds all the strings in the file.
|
||||
//---------------------------------------------------------------------
|
||||
long filesize;
|
||||
HRSRC hRsrc;
|
||||
HGLOBAL hGlobal;
|
||||
|
||||
HMODULE module = GetModuleHandle( NULL );
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Find the string file in this program's resources.
|
||||
//-------------------------------------------------------------------------
|
||||
switch( CodePage ) {
|
||||
|
||||
// Japanese
|
||||
case 932:
|
||||
PrimaryLanguage = LANG_JAPANESE;
|
||||
SubLanguage = SUBLANG_DEFAULT;
|
||||
break;
|
||||
|
||||
// Korean
|
||||
case 949:
|
||||
PrimaryLanguage = LANG_KOREAN;
|
||||
SubLanguage = SUBLANG_DEFAULT;
|
||||
break;
|
||||
|
||||
// Chinese
|
||||
case 950:
|
||||
PrimaryLanguage = LANG_CHINESE;
|
||||
SubLanguage = SUBLANG_DEFAULT;
|
||||
break;
|
||||
|
||||
// English, French, and German
|
||||
case 1252:
|
||||
|
||||
switch( LanguageID ) {
|
||||
|
||||
case LANG_GERMAN:
|
||||
PrimaryLanguage = LANG_GERMAN;
|
||||
SubLanguage = SUBLANG_GERMAN;
|
||||
break;
|
||||
|
||||
case LANG_FRENCH:
|
||||
PrimaryLanguage = LANG_FRENCH;
|
||||
SubLanguage = SUBLANG_FRENCH;
|
||||
break;
|
||||
|
||||
case LANG_ENGLISH:
|
||||
PrimaryLanguage = LANG_ENGLISH;
|
||||
SubLanguage = SUBLANG_ENGLISH_US;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
hRsrc = FindResourceEx( module, RT_RCDATA, "STRINGS", MAKELANGID( PrimaryLanguage, SubLanguage ));
|
||||
if ( hRsrc == NULL ) {
|
||||
hRsrc = FindResourceEx( module, RT_RCDATA, "STRINGS", MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US ));
|
||||
}
|
||||
if ( hRsrc ) {
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Load the resource, lock the memory, grab a DC.
|
||||
//---------------------------------------------------------------------
|
||||
hGlobal = LoadResource( module, hRsrc );
|
||||
filesize = SizeofResource( module, hRsrc );
|
||||
|
||||
LocaleFile = (void*)malloc( filesize + 1 );
|
||||
memset( LocaleFile, '\0', filesize + 1 );
|
||||
memcpy( LocaleFile, (const void *)hGlobal, filesize );
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Free DS and memory used.
|
||||
//---------------------------------------------------------------------
|
||||
UnlockResource( hGlobal );
|
||||
FreeResource( hGlobal );
|
||||
}
|
||||
|
||||
if( LocaleFile == NULL ) {
|
||||
LocaleFile = Load_File( LanguageFile, &filesize );
|
||||
}
|
||||
|
||||
if( LocaleFile != NULL ) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Set the LanguageID because we may need this later.
|
||||
//---------------------------------------------------------------------
|
||||
// CHAR buffer[ _MAX_PATH ];
|
||||
|
||||
// Locale_GetString( LANG_NUM, buffer );
|
||||
// LanguageID = atoi( buffer );
|
||||
|
||||
LanguageID = 0;
|
||||
|
||||
#if(_DEBUG)
|
||||
switch( LanguageID ) {
|
||||
case 6:
|
||||
CodePage = 932;
|
||||
break;
|
||||
case 9:
|
||||
CodePage = 949;
|
||||
break;
|
||||
case 10:
|
||||
CodePage = 950;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
*/
|
||||
return result;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* restore */
|
||||
/************************************************************************/
|
||||
|
||||
void Locale_Restore ( void )
|
||||
{
|
||||
if (TheGameText)
|
||||
{
|
||||
delete TheGameText;
|
||||
TheGameText = NULL;
|
||||
}
|
||||
|
||||
#if( USE_MULTI_FILE_FORMAT )
|
||||
LOCALE_freetable();
|
||||
LOCALE_restore();
|
||||
#else
|
||||
if( LocaleFile ) {
|
||||
free( LocaleFile );
|
||||
LocaleFile = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* retreiving strings */
|
||||
/****************************************************************************/
|
||||
|
||||
const char* Locale_GetString( int StringID, char *String )
|
||||
{
|
||||
static char buffer[ _MAX_PATH ];
|
||||
static wchar_t wide_buffer[ _MAX_PATH ];
|
||||
|
||||
memset( buffer, '\0', _MAX_PATH );
|
||||
memset( wide_buffer, '\0', _MAX_PATH );
|
||||
|
||||
#if( USE_MULTI_FILE_FORMAT )
|
||||
wcscpy( wide_buffer, (wchar_t *)LOCALE_getstring( StringID ));
|
||||
#else
|
||||
wcscpy( wide_buffer, (wchar_t *)LOCALE_getstr( LocaleFile, StringID ));
|
||||
#endif
|
||||
|
||||
Remove_Quotes_Around_String( wide_buffer );
|
||||
WideCharToMultiByte( CodePage, 0, wide_buffer, _MAX_PATH, buffer, _MAX_PATH, NULL, NULL );
|
||||
|
||||
if( String != NULL ) {
|
||||
strncpy( String, buffer, _MAX_PATH );
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const wchar_t* Locale_GetString( const char *id, wchar_t *buffer, int size )
|
||||
{
|
||||
if (TheGameText)
|
||||
{
|
||||
const wchar_t *fetched = TheGameText->fetch(id);
|
||||
if (buffer)
|
||||
{
|
||||
wcsncpy(buffer, fetched, size);
|
||||
buffer[size-1] = 0;
|
||||
}
|
||||
return fetched;
|
||||
}
|
||||
return L"No String Manager";
|
||||
}
|
||||
|
||||
/*
|
||||
const wchar_t* Locale_GetString( int StringID, wchar_t *String )
|
||||
{
|
||||
static wchar_t wide_buffer[ _MAX_PATH ];
|
||||
|
||||
memset( wide_buffer, '\0', _MAX_PATH );
|
||||
|
||||
#if( USE_MULTI_FILE_FORMAT )
|
||||
wcscpy( wide_buffer, (wchar_t *)LOCALE_getstring( StringID ));
|
||||
#else
|
||||
|
||||
wchar_t *localeStr = NULL;
|
||||
|
||||
if (TheGameText != NULL)
|
||||
localeStr = (wchar_t *)TheGameText->fetch( s_stringLabels[StringID] );
|
||||
|
||||
if (localeStr == NULL)
|
||||
{
|
||||
return localeStringsMissing[ min( MISSING_STRING_HINTS_MAX - 1, StringID ) ];
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy( wide_buffer, localeStr);
|
||||
}
|
||||
#endif
|
||||
|
||||
Remove_Quotes_Around_String( wide_buffer );
|
||||
|
||||
if( String != NULL ) {
|
||||
wcsncpy( String, wide_buffer, _MAX_PATH );
|
||||
}
|
||||
|
||||
return wide_buffer;
|
||||
}
|
||||
*/
|
||||
|
||||
/****************************************************************************/
|
||||
/* formating strings */
|
||||
/****************************************************************************/
|
||||
|
||||
wchar_t *Remove_Quotes_Around_String ( wchar_t *old_string )
|
||||
{
|
||||
wchar_t wide_buffer[ _MAX_PATH ];
|
||||
wchar_t *letter = old_string;
|
||||
int length;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// If string is not NULL...
|
||||
//----------------------------------------------------------------------
|
||||
if ( *letter == '"' ) {
|
||||
|
||||
letter++;
|
||||
wcscpy( wide_buffer, letter );
|
||||
|
||||
length = wcslen( wide_buffer );
|
||||
|
||||
if ( wide_buffer[ wcslen( wide_buffer )-1 ] == '"' ) {
|
||||
wide_buffer[ wcslen( wide_buffer )-1 ] = '\0';
|
||||
}
|
||||
wcscpy( old_string, wide_buffer );
|
||||
}
|
||||
|
||||
return( old_string );
|
||||
}
|
||||
|
||||
|
||||
|
67
Generals/Code/Tools/Autorun/Locale_API.h
Normal file
67
Generals/Code/Tools/Autorun/Locale_API.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************************************************************
|
||||
* C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S *
|
||||
*************************************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/Locale_API.h $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 1/15/02 2:16p $
|
||||
* $Revision: 5 $
|
||||
*
|
||||
*************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef LOCALE_API_H
|
||||
#define LOCALE_API_H
|
||||
|
||||
#include <STDLIB.H>
|
||||
|
||||
/****************************************************************************/
|
||||
/* GLOBAL VARIABLES */
|
||||
/****************************************************************************/
|
||||
extern int CodePage;
|
||||
extern void * LocaleFile;
|
||||
extern int LanguageID;
|
||||
extern char LanguageFile[];
|
||||
extern int PrimaryLanguage;
|
||||
extern int SubLanguage;
|
||||
|
||||
/****************************************************************************/
|
||||
/* LOCALE API */
|
||||
/****************************************************************************/
|
||||
int Locale_Init ( int language, char *file );
|
||||
void Locale_Restore ( void );
|
||||
const wchar_t* Locale_GetString( const char *id, wchar_t *buffer = NULL, int size = _MAX_PATH );
|
||||
/*
|
||||
const char* Locale_GetString ( int StringID, char *String );
|
||||
const wchar_t* Locale_GetString ( int StringID, wchar_t *String=NULL );
|
||||
*/
|
||||
bool Locale_Use_Multi_Language_Files ( void );
|
||||
//int Locale_Get_Language_ID ( void ) { return LanguageID; };
|
||||
|
||||
#endif
|
238
Generals/Code/Tools/Autorun/POINT.h
Normal file
238
Generals/Code/Tools/Autorun/POINT.h
Normal file
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name: Command & Conquer *
|
||||
* *
|
||||
* Archive: /Sun/Point.h *
|
||||
* *
|
||||
* Author: Joe_b *
|
||||
* *
|
||||
* Modtime: 2/02/98 10:09a *
|
||||
* *
|
||||
* Revision: 24 *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
#pragma once
|
||||
|
||||
#ifndef POINT_H
|
||||
#define POINT_H
|
||||
|
||||
#include <math.h>
|
||||
//#include "always.h"
|
||||
//#include "cctypes.h"
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C"{
|
||||
//#endif
|
||||
|
||||
//#pragma pack(1)
|
||||
|
||||
typedef struct Point2DStruct
|
||||
{
|
||||
int X;
|
||||
int Y;
|
||||
} Point2DStruct;
|
||||
|
||||
//#pragma pack()
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
template<class T> class TRect;
|
||||
|
||||
/***********************************************************************************************
|
||||
** This class describes a point in 2 dimensional space using arbitrary
|
||||
** components. The interpretation of which is outside the scope
|
||||
** of this class. This class is the successor to the old style COORDINATE
|
||||
** and CELL types but also serves anywhere an X and Y value are treated
|
||||
** as a logical object (e.g., pixel location).
|
||||
*/
|
||||
template<class T>
|
||||
class TPoint2D {
|
||||
public:
|
||||
TPoint2D(void) {} // Default constructor does nothing by design.
|
||||
TPoint2D(T x, T y) : X(x), Y(y) {}
|
||||
|
||||
// Equality comparison operators.
|
||||
bool operator == (TPoint2D<T> const & rvalue) const {return(X==rvalue.X && Y==rvalue.Y);}
|
||||
bool operator != (TPoint2D<T> const & rvalue) const {return(X!=rvalue.X || Y!=rvalue.Y);}
|
||||
|
||||
// Addition and subtraction operators.
|
||||
TPoint2D<T> const & operator += (TPoint2D<T> const & rvalue) {X += rvalue.X;Y += rvalue.Y;return(*this);}
|
||||
TPoint2D<T> const & operator -= (TPoint2D<T> const & rvalue) {X -= rvalue.X;Y -= rvalue.Y;return(*this);}
|
||||
TPoint2D<T> const operator - (TPoint2D<T> const & rvalue) const {return(TPoint2D<T>(T(X - rvalue.X), T(Y - rvalue.Y)));}
|
||||
TPoint2D<T> const operator + (TPoint2D<T> const & rvalue) const {return(TPoint2D<T>(T(X + rvalue.X), T(Y + rvalue.Y)));}
|
||||
|
||||
// Scalar multiplication and division.
|
||||
TPoint2D<T> const operator * (T rvalue) const {return(TPoint2D<T>(T(X * rvalue), T(Y * rvalue)));}
|
||||
TPoint2D<T> const & operator *= (T rvalue) {X *= rvalue; Y *= rvalue;return(*this);}
|
||||
TPoint2D<T> const operator / (T rvalue) const {if (rvalue == T(0)) return(TPoint2D<T>(0,0));return(TPoint2D<T>(T(X / rvalue), T(Y / rvalue)));}
|
||||
TPoint2D<T> const & operator /= (T rvalue) {if (rvalue != T(0)) {X /= rvalue;Y /= rvalue;}return(*this);}
|
||||
|
||||
// Dot and cross product.
|
||||
TPoint2D<T> const operator * (TPoint2D<T> const & rvalue) const {return(TPoint2D<T>(T(X * rvalue.X), T(Y * rvalue.Y)));}
|
||||
T Dot_Product(TPoint2D<T> const & rvalue) const {return((T(X * rvalue.X + Y * rvalue.Y)));}
|
||||
TPoint2D<T> const Cross_Product(TPoint2D<T> const & rvalue) const {return(TPoint2D<T>(T(Y - rvalue.Y), T(rvalue.X - X)));}
|
||||
|
||||
// Negation operator -- simple and effective
|
||||
TPoint2D<T> const operator - (void) const {return(TPoint2D<T>(T(-X), T(-Y)));}
|
||||
|
||||
// Vector support functions.
|
||||
T Length(void) const {return(T(sqrt(double(X*X + Y*Y))));}
|
||||
TPoint2D<T> const Normalize(void) const {
|
||||
double len = sqrt(X*X + Y*Y);
|
||||
if (len != 0.0) {
|
||||
return(TPoint2D<T>((T)(X / len), (T)(Y / len)));
|
||||
} else {
|
||||
return(*this);
|
||||
}
|
||||
}
|
||||
|
||||
// Find distance between points.
|
||||
T Distance_To(TPoint2D<T> const & point) const {return((*this - point).Length());}
|
||||
|
||||
public:
|
||||
T X;
|
||||
T Y;
|
||||
};
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
** This typedef provides an uncluttered type name for use by simple integer points.
|
||||
*/
|
||||
class Point2D : public TPoint2D<int>
|
||||
{
|
||||
public:
|
||||
Point2D(void) {} // Default constructor does nothing by design.
|
||||
Point2D(int x, int y) : TPoint2D<int>(x, y) {}
|
||||
Point2D(Point2DStruct const & rvalue) : TPoint2D<int>(rvalue.X, rvalue.Y) {}
|
||||
Point2D(TPoint2D<int> const & rvalue) : TPoint2D<int>(rvalue) {}
|
||||
|
||||
operator Point2DStruct (void) const {Point2DStruct pt;pt.X = X;pt.Y = Y;return(pt);}
|
||||
|
||||
Point2D const & operator += (Point2D const & rvalue) {X += rvalue.X;Y += rvalue.Y;return(*this);}
|
||||
Point2D const & operator -= (Point2D const & rvalue) {X -= rvalue.X;Y -= rvalue.Y;return(*this);}
|
||||
Point2D const operator - (Point2D const & rvalue) const {return(Point2D(int(X - rvalue.X), int(Y - rvalue.Y)));}
|
||||
Point2D const operator + (Point2D const & rvalue) const {return(Point2D(int(X + rvalue.X), int(Y + rvalue.Y)));}
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
T Distance(TPoint2D<T> const & point1, TPoint2D<T> const & point2)
|
||||
{
|
||||
return((point1 - point2).Length());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
TPoint2D<T> const Cross_Product(TPoint2D<T> const & lvalue, TPoint2D<T> const & rvalue)
|
||||
{
|
||||
return(lvalue.Cross_Product(rvalue));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
** This describes a point in 3 dimensional space using arbitrary
|
||||
** components. This is the successor to the COORDINATE type for those
|
||||
** times when height (Z axis) needs to be tracked.
|
||||
**
|
||||
** Notice that it is NOT implemented as a virtually derived class. This
|
||||
** is for efficiency reasons. This class chooses to be smaller and faster at the
|
||||
** expense of polymorphism. However, since it is publicly derived, inheritance is
|
||||
** the next best thing.
|
||||
*/
|
||||
template<class T>
|
||||
class TPoint3D : public TPoint2D<T> {
|
||||
typedef TPoint2D<T> BASECLASS;
|
||||
|
||||
public:
|
||||
TPoint3D(void) {} // Default constructor does nothing by design.
|
||||
TPoint3D(T x, T y, T z) : BASECLASS(x, y), Z(z) {}
|
||||
TPoint3D(BASECLASS const & rvalue, T z /*= 0*/) : BASECLASS(rvalue), Z(z) {}
|
||||
|
||||
// Equality comparison operators.
|
||||
bool operator == (TPoint3D<T> const & rvalue) const {return(X==rvalue.X && Y==rvalue.Y && Z==rvalue.Z);}
|
||||
bool operator != (TPoint3D<T> const & rvalue) const {return(X!=rvalue.X || Y!=rvalue.Y || Z!=rvalue.Z);}
|
||||
|
||||
// Addition and subtraction operators.
|
||||
TPoint3D<T> const & operator += (TPoint3D<T> const & rvalue) {X += rvalue.X;Y += rvalue.Y;Z += rvalue.Z;return(*this);}
|
||||
TPoint2D<T> const & operator += (TPoint2D<T> const & rvalue) {BASECLASS::operator += (rvalue);return(*this);}
|
||||
TPoint3D<T> const & operator -= (TPoint3D<T> const & rvalue) {X -= rvalue.X;Y -= rvalue.Y;Z -= rvalue.Z;return(*this);}
|
||||
TPoint2D<T> const & operator -= (TPoint2D<T> const & rvalue) {BASECLASS::operator -= (rvalue);return(*this);}
|
||||
TPoint3D<T> const operator - (TPoint3D<T> const & rvalue) const {return(TPoint3D<T>(X - rvalue.X, Y - rvalue.Y, Z - rvalue.Z));}
|
||||
TPoint3D<T> const operator - (TPoint2D<T> const & rvalue) const {return(TPoint3D<T>(X - rvalue.X, Y - rvalue.Y, Z));}
|
||||
TPoint3D<T> const operator + (TPoint3D<T> const & rvalue) const {return(TPoint3D<T>(X + rvalue.X, Y + rvalue.Y, Z + rvalue.Z));}
|
||||
TPoint3D<T> const operator + (TPoint2D<T> const & rvalue) const {return(TPoint3D<T>(X + rvalue.X, Y + rvalue.Y, Z));}
|
||||
|
||||
// Scalar multiplication and division.
|
||||
TPoint3D<T> const operator * (T rvalue) const {return(TPoint3D<T>(X * rvalue, Y * rvalue, Z * rvalue));}
|
||||
TPoint3D<T> const & operator *= (T rvalue) {X *= rvalue;Y *= rvalue;Z *= rvalue;return(*this);}
|
||||
TPoint3D<T> const operator / (T rvalue) const {if (rvalue == T(0)) return(TPoint3D<T>(0,0,0));return(TPoint3D<T>(X / rvalue, Y / rvalue, Z / rvalue));}
|
||||
TPoint3D<T> const & operator /= (T rvalue) {if (rvalue != T(0)) {X /= rvalue;Y /= rvalue;Z /= rvalue;}return(*this);}
|
||||
|
||||
// Dot and cross product.
|
||||
TPoint3D<T> const operator * (TPoint3D<T> const & rvalue) const {return(TPoint3D<T>(X * rvalue.X, Y * rvalue.Y, Z * rvalue.Z));}
|
||||
T Dot_Product(TPoint3D<T> const & rvalue) const {return(T(X * rvalue.X + Y * rvalue.Y + Z * rvalue.Z));}
|
||||
TPoint3D<T> const Cross_Product(TPoint3D<T> const & rvalue) const {return TPoint3D<T>(Y * rvalue.Z - Z * rvalue.Y, Z * rvalue.X - X * rvalue.Z, X * rvalue.Y - Y * rvalue.X);}
|
||||
|
||||
// Negation operator -- simple and effective
|
||||
TPoint3D<T> const operator - (void) const {return(TPoint3D<T>(-X, -Y, -Z));}
|
||||
|
||||
// Vector support functions.
|
||||
T Length(void) const {return(T(sqrt(double(X*X + Y*Y + Z*Z))));}
|
||||
TPoint3D<T> const Normalize(void) const {
|
||||
double len = sqrt(X*X + Y*Y + Z*Z);
|
||||
if (len != 0.0) {
|
||||
return(TPoint3D<T>((T)(X / len), (T)(Y / len), (T)(Z / len)));
|
||||
} else {
|
||||
return(*this);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
** The Z component of this point.
|
||||
*/
|
||||
T Z;
|
||||
};
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
** This typedef provides a simple uncluttered type name for use by
|
||||
** integer 3D points.
|
||||
*/
|
||||
typedef TPoint3D<int> Point3D;
|
||||
|
||||
template<class T>
|
||||
TPoint3D<T> const Cross_Product(TPoint3D<T> const & lvalue, TPoint3D<T> const & rvalue)
|
||||
{
|
||||
return(lvalue.Cross_Product(rvalue));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
308
Generals/Code/Tools/Autorun/RECT.h
Normal file
308
Generals/Code/Tools/Autorun/RECT.h
Normal file
|
@ -0,0 +1,308 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer *
|
||||
* *
|
||||
* Archive : /Sun/RECT.H *
|
||||
* *
|
||||
* Author : Joe_b *
|
||||
* *
|
||||
* Modtime : 11/21/97 4:40p *
|
||||
* *
|
||||
* Revision : 20 *
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Union -- Combines two rectangles into one larger one. *
|
||||
* Intersect -- Find the intersection between two rectangles. *
|
||||
* Intersect -- Simple intersect between two rectangles. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
#pragma once
|
||||
|
||||
#ifndef RECT_H
|
||||
#define RECT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "point.h"
|
||||
|
||||
|
||||
/*
|
||||
** This class manages a rectangle. Typically, this is used for tracking regions on a surface
|
||||
** and for clipping operations. This is a lightweight class in that it defines few support
|
||||
** functions and exposes the member variables for direct access.
|
||||
*/
|
||||
template<class T>
|
||||
class TRect
|
||||
{
|
||||
public:
|
||||
TRect(void) {} // Default constructor does nothing by design.
|
||||
TRect(T x, T y, T w, T h) : X(x), Y(y), Width(w), Height(h) {}
|
||||
TRect(TPoint2D<T> const & point, T w, T h) : X(point.X), Y(point.Y), Width(w), Height(h) {}
|
||||
|
||||
// Equality comparison operators.
|
||||
bool operator == (TRect<T> const & rvalue) const {return(X==rvalue.X && Y==rvalue.Y && Width==rvalue.Width && Height==rvalue.Height);}
|
||||
bool operator != (TRect<T> const & rvalue) const {return(X!=rvalue.X || Y!=rvalue.Y || Width!=rvalue.Width || Height!=rvalue.Height);}
|
||||
|
||||
// Addition and subtraction operators.
|
||||
TRect<T> const & operator += (TPoint2D<T> const & point) {X += point.X;Y += point.Y;return(*this);}
|
||||
TRect<T> const & operator -= (TPoint2D<T> const & point) {X -= point.X;Y -= point.Y;return(*this);}
|
||||
TRect<T> const operator + (TPoint2D<T> const & point) {return(TRect<T>(Top_Left() + point, Width, Height));}
|
||||
TRect<T> const operator - (TPoint2D<T> const & point) {return(TRect<T>(Top_Left() - point, Width, Height));}
|
||||
|
||||
/*
|
||||
** Bias this rectangle within another.
|
||||
*/
|
||||
TRect<T> const Bias_To(TRect<T> const & rect) const {return(TRect<T>(Top_Left() + rect.Top_Left(), Width, Height));}
|
||||
|
||||
// Assign values
|
||||
void Set(T x, T y, T w, T h) {X = x; Y = y; Width = w; Height = h;}
|
||||
|
||||
/*
|
||||
** Determine if two rectangles overlap.
|
||||
*/
|
||||
bool Is_Overlapping(TRect<T> const & rect) const {return(X < rect.X+rect.Width && Y < rect.Y+rect.Height && X+Width > rect.X && Y+Height > rect.Y);}
|
||||
|
||||
/*
|
||||
** Determine is rectangle is valid.
|
||||
*/
|
||||
bool Is_Valid(void) const {return(Width > 0 && Height > 0);}
|
||||
__declspec(property(get=Is_Valid)) bool IsValid;
|
||||
|
||||
/*
|
||||
** Returns size of rectangle if each discrete location within it is presumed
|
||||
** to be of size 1.
|
||||
*/
|
||||
int Size(void) const {return(int(Width) * int(Height));}
|
||||
|
||||
/*
|
||||
** Fetch points of rectangle (used as a convenience for the programmer).
|
||||
*/
|
||||
TPoint2D<T> Top_Left(void) const {return(TPoint2D<T>(X, Y));}
|
||||
__declspec(property(get=Top_Left)) TPoint2D<T> TopLeft;
|
||||
|
||||
TPoint2D<T> Top_Right(void) const {return(TPoint2D<T>(T(X + Width - 1), Y));}
|
||||
__declspec(property(get=Top_Right)) TPoint2D<T> TopRight;
|
||||
|
||||
TPoint2D<T> Bottom_Left(void) const {return(TPoint2D<T>(X, T(Y + Height - 1)));}
|
||||
__declspec(property(get=Bottom_Left)) TPoint2D<T> BottomLeft;
|
||||
|
||||
TPoint2D<T> Bottom_Right(void) const {return(TPoint2D<T>(T(X + Width - 1), T(Y + Height - 1)));}
|
||||
__declspec(property(get=Bottom_Right)) TPoint2D<T> BottomRight;
|
||||
|
||||
|
||||
/*
|
||||
** Determine if a point lies within the rectangle.
|
||||
*/
|
||||
bool Is_Point_Within(TPoint2D<T> const & point) const {return(point.X >= X && point.X < X+Width && point.Y >= Y && point.Y < Y+Height);}
|
||||
|
||||
public:
|
||||
|
||||
/*
|
||||
** Coordinate of upper left corner of rectangle.
|
||||
*/
|
||||
T X;
|
||||
T Y;
|
||||
|
||||
/*
|
||||
** Dimensions of rectangle. If the width or height is less than or equal to
|
||||
** zero, then the rectangle is in an invalid state.
|
||||
*/
|
||||
T Width;
|
||||
T Height;
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
TPoint2D<T> const Bias_To(TPoint2D<T> const & point, TRect<T> const & rect)
|
||||
{
|
||||
return(TPoint2D<T>(T(point.X + rect.X), T(point.Y + rect.Y)));
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Union -- Combines two rectangles into one larger one. *
|
||||
* *
|
||||
* This routine will combine the two specified rectangles such that a larger one is *
|
||||
* returned that encompasses both rectangles. *
|
||||
* *
|
||||
* INPUT: rect1 -- One rectangle to combine. *
|
||||
* rect2 -- The other rectangle to combine. *
|
||||
* *
|
||||
* OUTPUT: Returns with the smallest rectangle that encompasses both specified rectangles. *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/04/1997 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
template<class T>
|
||||
TRect<T> const Union(TRect<T> const & rect1, TRect<T> const & rect2)
|
||||
{
|
||||
if (rect1.Is_Valid()) {
|
||||
if (rect2.Is_Valid()) {
|
||||
TRect<T> result = rect1;
|
||||
|
||||
if (result.X > rect2.X) {
|
||||
result.Width += T(result.X-rect2.X);
|
||||
result.X = rect2.X;
|
||||
}
|
||||
if (result.Y > rect2.Y) {
|
||||
result.Height += T(result.Y-rect2.Y);
|
||||
result.Y = rect2.Y;
|
||||
}
|
||||
if (result.X+result.Width < rect2.X+rect2.Width) {
|
||||
result.Width = T(((rect2.X+rect2.Width)-result.X)+1);
|
||||
}
|
||||
if (result.Y+result.Height < rect2.Y+rect2.Height) {
|
||||
result.Height = T(((rect2.Y+rect2.Height)-result.Y)+1);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
return(rect1);
|
||||
}
|
||||
return(rect2);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Intersect -- Find the intersection between two rectangles. *
|
||||
* *
|
||||
* This routine will take two rectangles and return the intersecting rectangle. It also *
|
||||
* tracks how much on rectangle was clipped off of the top and left edges and returns *
|
||||
* these values. It can be handy to use these returned clipping values for blit operations *
|
||||
* between rectangles. *
|
||||
* *
|
||||
* INPUT: bounding_rect -- The rectangle of the bounding box (clipping rectangle). *
|
||||
* *
|
||||
* draw_rect -- The rectangle that will be clipped into the bounding rectangle. *
|
||||
* *
|
||||
* x,y -- Place to store the clipping offset performed on the draw_rect. *
|
||||
* If this offset is applied to a subsiquent blit operation from *
|
||||
* the draw_rect source, it will appear to be properly clipped *
|
||||
* against the clipping rectangle rather than offset to the *
|
||||
* clipping rectangle. *
|
||||
* *
|
||||
* OUTPUT: Returns with the rectangle that is the intersection of the two rectangles. *
|
||||
* *
|
||||
* WARNINGS: The returned rectangle may be clipped into nothingness. Check for Is_Valid *
|
||||
* to catch this case. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/04/1997 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
template<class T>
|
||||
TRect<T> const Intersect(TRect<T> const & bounding_rect, TRect<T> const & draw_rect, T * x, T * y)
|
||||
{
|
||||
TRect<T> bad_rect(0, 0, 0, 0); // Dummy (illegal) draw_rect.
|
||||
TRect<T> new_draw_rect = draw_rect; // Working draw_rect.
|
||||
|
||||
/*
|
||||
** Both draw_rects must be valid or else no intersection can occur. In such
|
||||
** a case, return an illegal draw_rect.
|
||||
*/
|
||||
if (!bounding_rect.Is_Valid() || !draw_rect.Is_Valid()) return(bad_rect);
|
||||
|
||||
/*
|
||||
** The draw_rect spills past the left edge.
|
||||
*/
|
||||
if (new_draw_rect.X < bounding_rect.X) {
|
||||
new_draw_rect.Width -= T(bounding_rect.X - new_draw_rect.X);
|
||||
new_draw_rect.X = bounding_rect.X;
|
||||
}
|
||||
if (new_draw_rect.Width < 1) return(bad_rect);
|
||||
|
||||
/*
|
||||
** The draw_rect spills past top edge.
|
||||
*/
|
||||
if (new_draw_rect.Y < bounding_rect.Y) {
|
||||
new_draw_rect.Height -= T(bounding_rect.Y - new_draw_rect.Y);
|
||||
new_draw_rect.Y = bounding_rect.Y;
|
||||
}
|
||||
if (new_draw_rect.Height < 1) return(bad_rect);
|
||||
|
||||
/*
|
||||
** The draw_rect spills past the right edge.
|
||||
*/
|
||||
if (new_draw_rect.X + new_draw_rect.Width > bounding_rect.X + bounding_rect.Width) {
|
||||
new_draw_rect.Width -= T((new_draw_rect.X + new_draw_rect.Width) - (bounding_rect.X + bounding_rect.Width));
|
||||
}
|
||||
if (new_draw_rect.Width < 1) return(bad_rect);
|
||||
|
||||
/*
|
||||
** The draw_rect spills past the bottom edge.
|
||||
*/
|
||||
if (new_draw_rect.Y + new_draw_rect.Height > bounding_rect.Y + bounding_rect.Height) {
|
||||
new_draw_rect.Height -= T((new_draw_rect.Y + new_draw_rect.Height) - (bounding_rect.Y + bounding_rect.Height));
|
||||
}
|
||||
if (new_draw_rect.Height < 1) return(bad_rect);
|
||||
|
||||
/*
|
||||
** Adjust Height relative draw position according to Height new draw_rect
|
||||
** union.
|
||||
*/
|
||||
if (x != NULL) {
|
||||
*x -= T(new_draw_rect.X - draw_rect.X);
|
||||
}
|
||||
if (y != NULL) {
|
||||
*y -= T(new_draw_rect.Y - draw_rect.Y);
|
||||
}
|
||||
|
||||
return(new_draw_rect);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* Intersect -- Simple intersect between two rectangles. *
|
||||
* *
|
||||
* This will return with the rectangle that represents the intersection of the two *
|
||||
* rectangles specified. *
|
||||
* *
|
||||
* INPUT: rect1 -- The first rectangle. *
|
||||
* *
|
||||
* rect2 -- The second rectangle. *
|
||||
* *
|
||||
* OUTPUT: Returns with the intersecting rectangle between the two rectangles specified. *
|
||||
* *
|
||||
* WARNINGS: If there is no valid intersection between the two rectangles, then a rectangle *
|
||||
* of illegal value is returned. Check for this case by using the Is_Valid() *
|
||||
* function. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 06/04/1997 JLB : Created. *
|
||||
*=============================================================================================*/
|
||||
template<class T>
|
||||
TRect<T> const Intersect(TRect<T> const & rect1, TRect<T> const & rect2)
|
||||
{
|
||||
return(Intersect(rect1, rect2, (T*)NULL, (T*)NULL));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** This typedef provides an uncluttered type name for a rectangle that
|
||||
** is composed of integers.
|
||||
*/
|
||||
typedef TRect<int> Rect;
|
||||
|
||||
const Rect RECT_NONE(0,0,0,0);
|
||||
|
||||
#endif
|
||||
|
1475
Generals/Code/Tools/Autorun/TTFont.cpp
Normal file
1475
Generals/Code/Tools/Autorun/TTFont.cpp
Normal file
File diff suppressed because it is too large
Load diff
304
Generals/Code/Tools/Autorun/TTFont.h
Normal file
304
Generals/Code/Tools/Autorun/TTFont.h
Normal file
|
@ -0,0 +1,304 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
************************************************************************************************
|
||||
* *
|
||||
* Project Name: Setup *
|
||||
* *
|
||||
* Archive: ttfont.h *
|
||||
* *
|
||||
* Author: Joe_b *
|
||||
* *
|
||||
* Modtime: 6/23/97 3:14p *
|
||||
* *
|
||||
* Updated: 08/01/2000 [MML] *
|
||||
* *
|
||||
* Revision: 22 *
|
||||
* *
|
||||
*----------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
|
||||
#pragma once
|
||||
|
||||
#ifndef TTFONT_H
|
||||
#define TTFONT_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "point.h"
|
||||
#include "rect.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** These are the control flags for Fancy_Text_Print function.
|
||||
*/
|
||||
typedef enum TextPrintType {
|
||||
|
||||
TPF_LASTPOINT = 0x0000, // Use previous font point value.
|
||||
TPF_TT_10POINT = 0x0001, // True Type Font - 10 point
|
||||
TPF_TT_12POINT = 0x0002, // True Type Font - 12 point
|
||||
TPF_TT_14POINT = 0x000A, // True Type Font - 14 point
|
||||
TPF_TT_16POINT = 0x000B, // True Type Font - 16 point
|
||||
TPF_TT_18POINT = 0x000C, // True Type Font - 18 point
|
||||
TPF_TT_20POINT = 0x000D, // True Type Font - 20 point
|
||||
TPF_TT_22POINT = 0x000E, // True Type Font - 22 point
|
||||
TPF_TT_24POINT = 0x000F, // True Type Font - 24 point
|
||||
|
||||
TPF_BUTTON_FONT = 0x0010,
|
||||
TPF_TEXT_FONT = 0x0020,
|
||||
|
||||
} TextPrintType;
|
||||
|
||||
typedef enum TextShadowType {
|
||||
|
||||
TPF_NOSHADOW = 0x0000,
|
||||
TPF_DROPSHADOW = 0x0001, // Use a simple drop shadow.
|
||||
TPF_LIGHTSHADOW = 0x0002,
|
||||
TPF_FULLSHADOW = 0x0004, // Use a full outline shadow.
|
||||
TPF_DOUBLESHADOW = 0x0008, // Use a simple drop shadow.
|
||||
TPF_SHADOW = 0x0010, // Print twice, using backcolor.
|
||||
|
||||
} TextShadowType;
|
||||
|
||||
typedef enum TextFormatType {
|
||||
|
||||
TPF_TOP = DT_TOP, // Use with DT_SINGLELINE. Top-justifies text.
|
||||
TPF_VCENTER = DT_VCENTER, // Use with DT_SINGLELINE. Centers text vertically.
|
||||
TPF_BOTTOM = DT_BOTTOM, // Use with DT_SINGLELINE. Justifies test to the bottom of the rectangle.
|
||||
TPF_LEFT = DT_LEFT, // Aligns text to the left.
|
||||
TPF_CENTER = DT_CENTER, // Centers text horizontally in the rectangle.
|
||||
TPF_RIGHT = DT_RIGHT, // Right justify text.
|
||||
TPF_WORDBREAK = DT_WORDBREAK, // Lines are automatically broken between words.
|
||||
TPF_SINGLE_LINE = DT_SINGLELINE, // All text on one line only.
|
||||
TPF_NO_PREFIX = DT_NOPREFIX, // Turns off processing of prefix characters.
|
||||
TPF_PATH_ELLIPSIS = DT_PATH_ELLIPSIS, // For displayed text, replaces characters in the middle of the string with ellipses so that the result fits in the specified rectangle.
|
||||
|
||||
} TextFormatType;
|
||||
|
||||
/******************************************************************************
|
||||
** Standard button text print flags.
|
||||
*/
|
||||
//#define TPF_BUTTON (TextFormatType)( DT_VCENTER | DT_CENTER | DT_SINGLELINE )
|
||||
//#define TPF_CENTER_FORMAT (TextFormatType)( DT_VCENTER | DT_CENTER | DT_WORDBREAK )
|
||||
//#define TPF_CHECKBOX (TextFormatType)( DT_LEFT | DT_VCENTER | DT_WORDBREAK )
|
||||
//#define TPF_EDIT (TextFormatType)( DT_LEFT | DT_VCENTER )
|
||||
//#define TPF_DEFAULT (TextFormatType)( DT_LEFT | DT_WORDBREAK )
|
||||
|
||||
#define TPF_BUTTON (TextFormatType)( DT_CENTER | DT_VCENTER | DT_SINGLELINE )
|
||||
#define TPF_EDITBOX (TextFormatType)( DT_LEFT | DT_VCENTER | DT_SINGLELINE )
|
||||
#define TPF_RADIO (TextFormatType)( DT_LEFT | DT_WORDBREAK )
|
||||
#define TPF_CHECKBOX (TextFormatType)( DT_LEFT | DT_WORDBREAK )
|
||||
#define TPF_OUTER_SCROLL (TextFormatType)( DT_LEFT | DT_WORDBREAK )
|
||||
#define TPF_INNER_SCROLL (TextFormatType)( DT_LEFT | DT_SINGLELINE )
|
||||
|
||||
#define TPF_LEFT_TEXT (TextFormatType)( DT_LEFT | DT_WORDBREAK )
|
||||
#define TPF_CENTER_TEXT (TextFormatType)( DT_CENTER | DT_WORDBREAK )
|
||||
#define TPF_RIGHT_TEXT (TextFormatType)( DT_RIGHT | DT_WORDBREAK )
|
||||
|
||||
#define TPF_LEFT_TOP_ALIGNMENT (TextFormatType)( DT_LEFT | DT_TOP | DT_SINGLELINE )
|
||||
#define TPF_LEFT_BOTTOM_ALIGNMENT (TextFormatType)( DT_LEFT | DT_BOTTOM | DT_SINGLELINE )
|
||||
#define TPF_LEFT_JUSTIFY (TextFormatType)( DT_LEFT | DT_VCENTER | DT_SINGLELINE )
|
||||
|
||||
#define TPF_RIGHT_TOP_ALIGNMENT (TextFormatType)( DT_RIGHT | DT_TOP | DT_SINGLELINE )
|
||||
#define TPF_RIGHT_BOTTOM_ALIGNMENT (TextFormatType)( DT_RIGHT | DT_BOTTOM | DT_SINGLELINE )
|
||||
#define TPF_RIGHT_JUSTIFY (TextFormatType)( DT_RIGHT | DT_VCENTER | DT_SINGLELINE )
|
||||
|
||||
#define TPF_CENTER_TOP_ALIGNMENT (TextFormatType)( DT_CENTER | DT_TOP | DT_SINGLELINE )
|
||||
#define TPF_CENTER_BOTTOM_ALIGNMENT (TextFormatType)( DT_CENTER | DT_BOTTOM | DT_SINGLELINE )
|
||||
#define TPF_CENTER_JUSTIFY (TextFormatType)( DT_CENTER | DT_VCENTER | DT_SINGLELINE )
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** These are the control flags for Fancy_Text_Print function.
|
||||
*/
|
||||
typedef enum SpecialEffectType {
|
||||
TPF_NONE =0x0000, // No special effects needed.
|
||||
TPF_CUTOFF_AT_WIDTH =0x0001, // Don't print past the allowed width.
|
||||
TPF_BURST_MODE =0x0002, // Print text one letter at a time like a typewriter.
|
||||
TPF_SPECIAL_WRAP =0x0003, // Begin at a specified point but start next line at a point before the starting point.
|
||||
} SpecialEffectType;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** Global DC. Use it or create your own!
|
||||
*/
|
||||
extern HDC BackBufferDC;
|
||||
|
||||
/******************************************************************************
|
||||
** Global Colors for use throughout program.
|
||||
*/
|
||||
extern unsigned long TEXT_COLOR;
|
||||
extern unsigned long SHADOW_COLOR;
|
||||
extern unsigned long TEXT_NORMAL_COLOR;
|
||||
extern unsigned long TEXT_FOCUSED_COLOR;
|
||||
extern unsigned long TEXT_PRESSED_COLOR;
|
||||
extern unsigned long TEXT_NORMAL_SHADOW_COLOR;
|
||||
extern unsigned long TEXT_FOCUSED_SHADOW_COLOR;
|
||||
extern unsigned long TEXT_PRESSED_SHADOW_COLOR;
|
||||
|
||||
extern unsigned long WHITE_COLOR;
|
||||
extern unsigned long BLACK_COLOR;
|
||||
extern unsigned long RED_COLOR;
|
||||
extern unsigned long ORANGE_COLOR;
|
||||
extern unsigned long YELLOW_COLOR;
|
||||
extern unsigned long GREEN_COLOR;
|
||||
extern unsigned long BLUE_COLOR;
|
||||
extern unsigned long INDIGO_COLOR;
|
||||
extern unsigned long VIOLET_COLOR;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** This is a True Type Font class object to create and use True Type fonts.
|
||||
******************************************************************************/
|
||||
// Font Weight - Specifies the weight of the font in the range 0 through 1000.
|
||||
// For example, 400 is normal and 700 is bold.
|
||||
// If this value is zero, a default weight is used.
|
||||
//
|
||||
// The following values are defined for convenience:
|
||||
// FW_DONTCARE 0 FW_SEMIBOLD 600
|
||||
// FW_THIN 100 FW_DEMIBOLD 600
|
||||
// FW_EXTRALIGHT 200 FW_BOLD 700
|
||||
// FW_ULTRALIGHT 200 FW_EXTRABOLD 800
|
||||
// FW_LIGHT 300 FW_ULTRABOLD 800
|
||||
// FW_NORMAL 400 FW_HEAVY 900
|
||||
// FW_REGULAR 400 FW_BLACK 900
|
||||
// FW_MEDIUM 500
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class TTFontClass
|
||||
{
|
||||
public:
|
||||
|
||||
TTFontClass (
|
||||
HDC hdc,
|
||||
char * filename,
|
||||
char * facename,
|
||||
int height,
|
||||
int weight = FW_NORMAL,
|
||||
BYTE charset = ANSI_CHARSET,
|
||||
int width = 0,
|
||||
int escapement = 0,
|
||||
int orientation = 0,
|
||||
BYTE italic = FALSE,
|
||||
BYTE underline = FALSE,
|
||||
BYTE strikeout = FALSE,
|
||||
BYTE outputPrecision = OUT_TT_ONLY_PRECIS,
|
||||
BYTE clipPrecision = CLIP_DEFAULT_PRECIS,
|
||||
BYTE quality = PROOF_QUALITY,
|
||||
BYTE pitchAndFamily = FF_DONTCARE );
|
||||
|
||||
virtual ~TTFontClass(void)
|
||||
{
|
||||
if ( Font != NULL ) {
|
||||
DeleteObject( Font );
|
||||
Font = NULL;
|
||||
}
|
||||
RemoveFontResource( szFilename );
|
||||
};
|
||||
|
||||
virtual int Char_Pixel_Width ( HDC hdc, UINT c ) const;
|
||||
virtual int Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes=NULL ) const;
|
||||
virtual int String_Pixel_Width ( HDC hdc, char const * string ) const;
|
||||
virtual void String_Pixel_Bounds ( HDC hdc, const char * string, Rect& bounds ) const;
|
||||
virtual int Get_Width ( void ) const;
|
||||
virtual int Get_Height ( void ) const;
|
||||
virtual int Set_XSpacing ( HDC hdc, int x );
|
||||
virtual int Set_YSpacing ( int y );
|
||||
virtual int Find_Text_VLength ( HDC hdc, char *str, int width );
|
||||
virtual HFONT Get_Font_Ptr ( void ) { return Font; };
|
||||
virtual int IsFontDBCS ( void ) const { return ((CharSet==SHIFTJIS_CHARSET)||(CharSet==HANGEUL_CHARSET)||(CharSet==CHINESEBIG5_CHARSET)); }; // [OYO]
|
||||
virtual UINT Get_Double_Byte_Char ( const char *string, int *num_bytes=NULL ) const;
|
||||
|
||||
virtual Point2D Print(
|
||||
HDC hdc,
|
||||
char const * string,
|
||||
Rect const & cliprect,
|
||||
COLORREF forecolor = TEXT_COLOR,
|
||||
COLORREF backcolor = TEXT_NORMAL_SHADOW_COLOR,
|
||||
TextFormatType flag = TPF_LEFT_TEXT,
|
||||
TextShadowType shadow = TPF_NOSHADOW );
|
||||
|
||||
virtual Point2D Print(
|
||||
HDC hdc,
|
||||
wchar_t const * string,
|
||||
Rect const & cliprect,
|
||||
COLORREF forecolor = TEXT_COLOR,
|
||||
COLORREF backcolor = TEXT_NORMAL_SHADOW_COLOR,
|
||||
TextFormatType flag = TPF_LEFT_TEXT,
|
||||
TextShadowType shadow = TPF_NOSHADOW );
|
||||
|
||||
private:
|
||||
|
||||
HFONT Font;
|
||||
long Height;
|
||||
long Ascent;
|
||||
long Descent;
|
||||
long InternalLeading;
|
||||
long ExternalLeading;
|
||||
long AveCharWidth;
|
||||
long MaxCharWidth;
|
||||
long Overhang;
|
||||
long Italic;
|
||||
long Underlined;
|
||||
long StruckOut;
|
||||
int CharSet; // [OYO]
|
||||
int FontXSpacing; // GetTextCharacterExtra;
|
||||
int FontYSpacing;
|
||||
char szFacename[ MAX_PATH ];
|
||||
char szFilename[ MAX_PATH ];
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Global functions.
|
||||
//-------------------------------------------------------------------------
|
||||
TTFontClass * Font_From_TPF ( TextPrintType flags ); // Returns FontPtr based on flags passed in.
|
||||
bool Is_True_Type_Font ( TextPrintType flags ); // True Type???
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// This class is a wrapper around all the fonts that we want to be available.
|
||||
// The constructer will make them, and the destructor will remove them for us.
|
||||
//-------------------------------------------------------------------------
|
||||
class FontManagerClass
|
||||
{
|
||||
public:
|
||||
FontManagerClass ( HDC hdc );
|
||||
~FontManagerClass ( void );
|
||||
TTFontClass * Get_Font ( TextPrintType flags ) { return( Font_From_TPF( flags )); };
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** FontManager Class Pointer.
|
||||
*/
|
||||
extern FontManagerClass *FontManager;
|
||||
|
||||
/******************************************************************************
|
||||
** Loaded data file pointers.
|
||||
*/
|
||||
extern TTFontClass *TTButtonFontPtr;
|
||||
extern TTFontClass *TTButtonFontPtrSmall;
|
||||
extern TTFontClass *TTTextFontPtr;
|
||||
extern TTFontClass *TTTextFontPtr640;
|
||||
extern TTFontClass *TTTextFontPtr800;
|
||||
extern TTFontClass *TTLicenseFontPtr;
|
||||
|
||||
|
||||
#endif
|
669
Generals/Code/Tools/Autorun/Utils.cpp
Normal file
669
Generals/Code/Tools/Autorun/Utils.cpp
Normal file
|
@ -0,0 +1,669 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
****************************************************************************
|
||||
* *
|
||||
* Project Name : Setup *
|
||||
* *
|
||||
* File Name : UTILS.C *
|
||||
* *
|
||||
* Programmers: Maria del Mar McCready Legg *
|
||||
* *
|
||||
* Start Date : December 12, 1992 *
|
||||
* *
|
||||
* Last Update : March 16, 1998 [MML] *
|
||||
* *
|
||||
*--------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* *
|
||||
* Clip_Line_To_Rect -- Clips a line (two points) against a *
|
||||
* rectangle, using CS algorithm. *
|
||||
* Compute_Code -- computes line clipping bit code for *
|
||||
* point & rectangle. *
|
||||
* Copy_File -- Copies a file from one dir to another. *
|
||||
* Convert_Hex_To_Version -- Converts a hex num obtained from the *
|
||||
* Registry, into a string *
|
||||
* representation of a version *
|
||||
* number ( XX.XX ). *
|
||||
* Convert_Version_To_Hex -- Converts a string to an unsigned long. *
|
||||
* Convert_To_Version_Format -- Converts version string's "," to "."s *
|
||||
* Dialog_Box -- draws a dialog background box *
|
||||
* Draw_Box -- Displays a highlighted box. *
|
||||
* Fatal -- General purpose fatal error handler. *
|
||||
* Get_Version -- Retrieves a version string from a file. *
|
||||
* Get_String -- Returns a pointer to the undipped text. *
|
||||
* Is_File_Available -- Use both FindFirst to check that CD is *
|
||||
* in drive & if File_Exists() to *
|
||||
* determine if file is really there. *
|
||||
* Pad_With_Zeros -- Adds zeros to the beginning of string. *
|
||||
* String_Width -- Calculate with of the string. *
|
||||
* Strip_Newlines -- Remove '\r' from string passed in. *
|
||||
* TextPtr -- Returns a pointer to the undipped text. *
|
||||
* Path_Name_Valid -- Validate that the path has the correct *
|
||||
* number of chars between '\' in the *
|
||||
* path. *
|
||||
* Path_Get_Next_Directory -- Return the next dir path from string. *
|
||||
* Path_Add_Back_Slash -- Add a "\\" to the end of the string. *
|
||||
* Path_Remove_Back_Slash -- Remove a '\\' at the end of the string. *
|
||||
* Path_Trim_Blanks -- Trim lead/trail white spaces off string *
|
||||
* Pad_With_Zeros -- Adds zeros to the beginning of string. *
|
||||
* Remove_Ending_Spaces -- Remove any blank spaces at end of string*
|
||||
* Remove_Spaces -- Remove spaces from string passed in. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
|
||||
|
||||
#include <io.h>
|
||||
#include "args.h"
|
||||
#include "assert.h"
|
||||
#include "locale_api.h"
|
||||
#include "resource.h"
|
||||
#include "utils.h"
|
||||
#include "winfix.h"
|
||||
#include "wnd_file.h"
|
||||
#include <winver.h>
|
||||
#include <shlwapi.h>
|
||||
//#include "resources.h"
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Function: Fix_Single_Ampersands()
|
||||
//
|
||||
// Purpose: To replace each "&" with "&&" for display in a dialog.
|
||||
// Some dialogs mistake a single "&" for an accelerator key.
|
||||
//
|
||||
// Input: pszString - any NULL terminated string.
|
||||
//
|
||||
// Returns: VOID (returns nothing)
|
||||
//
|
||||
// Comments: Modifies the characters in pszString.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case )
|
||||
{
|
||||
char pszTemp[ MAX_PATH ]; // variable to hold the string passed
|
||||
char pszOld[ MAX_PATH ]; // variable to hold the string passed
|
||||
char * letter;
|
||||
int i = 0;
|
||||
|
||||
lstrcpy((LPSTR)pszOld, (LPSTR)pszString );
|
||||
letter = pszOld;
|
||||
memset ( pszTemp, '\0', MAX_PATH );
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// While our ptr has not passed the end of the string...
|
||||
//----------------------------------------------------------------------
|
||||
while (*letter != '\0') {
|
||||
|
||||
if (*letter == '&') {
|
||||
|
||||
pszTemp[i++] = '&';
|
||||
pszTemp[i++] = '&';
|
||||
letter++;
|
||||
|
||||
} else {
|
||||
|
||||
if ( upper_case ) {
|
||||
pszTemp[i++] = (char) toupper( *( letter++ ));
|
||||
} else {
|
||||
pszTemp[i++] = *(letter++);
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy((LPSTR)pszString, (LPSTR)pszTemp );
|
||||
}
|
||||
|
||||
void Fix_Single_Ampersands ( wchar_t *pszString, bool upper_case )
|
||||
{
|
||||
wchar_t pszTemp[ MAX_PATH ]; // variable to hold the string passed
|
||||
wchar_t pszOld[ MAX_PATH ]; // variable to hold the string passed
|
||||
wchar_t *letter;
|
||||
int i = 0;
|
||||
|
||||
wcscpy( pszOld, pszString );
|
||||
letter = pszOld;
|
||||
memset ( pszTemp, '\0', MAX_PATH );
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// While our ptr has not passed the end of the string...
|
||||
//----------------------------------------------------------------------
|
||||
while (*letter != '\0') {
|
||||
|
||||
if (*letter == '&') {
|
||||
|
||||
pszTemp[i++] = '&';
|
||||
pszTemp[i++] = '&';
|
||||
letter++;
|
||||
|
||||
} else {
|
||||
|
||||
if ( upper_case ) {
|
||||
pszTemp[i++] = (char) toupper( *( letter++ ));
|
||||
} else {
|
||||
pszTemp[i++] = *(letter++);
|
||||
}
|
||||
}
|
||||
}
|
||||
wcscpy( pszString, pszTemp );
|
||||
}
|
||||
|
||||
////////////////UnicodeString Fix_Single_Ampersands( UnicodeString string, bool upper_case)
|
||||
////////////////{
|
||||
//////////////// UnicodeString retval;
|
||||
////////////////
|
||||
//////////////// Int i = 0;
|
||||
//////////////// while (i < string.getLength()) {
|
||||
//////////////// if (upper_case) {
|
||||
//////////////// retval.concat(toupper(string.getCharAt(i)));
|
||||
//////////////// } else {
|
||||
//////////////// retval.concat(string.getCharAt(i));
|
||||
//////////////// }
|
||||
//////////////// if (string.getCharAt(i) == L'&') {
|
||||
//////////////// retval.concat(string.getCharAt(i));
|
||||
//////////////// }
|
||||
//////////////// ++i;
|
||||
//////////////// }
|
||||
////////////////
|
||||
//////////////// return retval;
|
||||
////////////////}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Function: Fix_Double_Ampersands()
|
||||
//
|
||||
// Purpose: To replace each "&&" with "&" for display in a dialog.
|
||||
// Some dialogs mistake a single "&" for an accelerator key.
|
||||
//
|
||||
// Input: pszString - any NULL terminated string.
|
||||
//
|
||||
// Returns: VOID (returns nothing)
|
||||
//
|
||||
// Comments: Modifies the characters in pszString.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Fix_Double_Ampersands ( LPSTR pszString, bool upper_case )
|
||||
{
|
||||
char pszTemp[ MAX_PATH ]; // variable to hold the string passed
|
||||
char pszOld[ MAX_PATH ]; // variable to hold the string passed
|
||||
char *letter;
|
||||
int i = 0;
|
||||
|
||||
lstrcpy( (LPSTR)pszOld, (LPSTR)pszString );
|
||||
letter = pszOld;
|
||||
memset ( pszTemp, '\0', MAX_PATH );
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// While our ptr has not passed the end of the string...
|
||||
//----------------------------------------------------------------------
|
||||
while (*letter != '\0') {
|
||||
|
||||
if ((*letter == '&') && (*( letter+1 ) == '&')) {
|
||||
|
||||
pszTemp[i++] = '&';
|
||||
letter = letter + 2;
|
||||
|
||||
} else {
|
||||
|
||||
if ( upper_case ) {
|
||||
pszTemp[i++] = (char) toupper( *( letter++ ));
|
||||
} else {
|
||||
pszTemp[i++] = *(letter++);
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy((LPSTR)pszString, (LPSTR)pszTemp );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Load_Alloc_Data -- Allocates a buffer and loads the file into it. *
|
||||
* *
|
||||
* This is the C++ replacement for the Load_Alloc_Data function. It will *
|
||||
* allocate the memory big enough to hold the file & read the file into it. *
|
||||
* *
|
||||
* INPUT: file -- The file to read. *
|
||||
* mem -- The memory system to use for allocation. *
|
||||
* *
|
||||
* OUTPUT: Returns with a pointer to the allocated and filled memory block. *
|
||||
* *
|
||||
* WARNINGS: none *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/17/1994 JLB : Created. *
|
||||
*============================================================================*/
|
||||
|
||||
void * Load_Alloc_Data( char *filename, long *filesize )
|
||||
{
|
||||
int size, bytes_read;
|
||||
void *ptr = NULL;
|
||||
StandardFileClass file;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Open file in READ ONLY mode. If fails, exit.
|
||||
//-------------------------------------------------------------------------
|
||||
file.Open( filename, MODE_READ_ONLY );
|
||||
if ( !file.Query_Open()) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Get filesize and create a buffer.
|
||||
//-------------------------------------------------------------------------
|
||||
size = file.Query_Size();
|
||||
ptr = (void*)malloc(size + 1);
|
||||
if ( !ptr ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Read data into the buffer, close the file.
|
||||
//-------------------------------------------------------------------------
|
||||
memset( ptr, '\0', size + 1 );
|
||||
bytes_read = file.Read( ptr, size );
|
||||
file.Close();
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Check return bytes. It should match the file size.
|
||||
//-------------------------------------------------------------------------
|
||||
assert( bytes_read == size );
|
||||
if ( bytes_read != size ) {
|
||||
free(ptr);
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if ( filesize != NULL ) {
|
||||
*filesize = (long)size;
|
||||
}
|
||||
return( ptr );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MIXFILECLASS::LOAD_FILE -- Returns a buffer loaded with file desired. *
|
||||
* *
|
||||
* INPUT: none. * *
|
||||
* *
|
||||
* OUTPUT: none. *
|
||||
* *
|
||||
* WARNINGS: Searches MixFile first, then local directory. *
|
||||
* Use free() to release buffer. * *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 04/13/1998 ML/MG : Created. *
|
||||
*==========================================================================*/
|
||||
|
||||
void *Load_File ( char *filename, long *filesize )
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
if ( filename == NULL || filename[0] == '\0' ) {
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Try loading from local directory.
|
||||
//-------------------------------------------------------------------------
|
||||
ptr = Load_Alloc_Data( filename, filesize );
|
||||
|
||||
return( ptr );
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* MAKE_CURRENT_PATH_TO -- Returns a buffer to path desired. *
|
||||
* *
|
||||
* INPUT: none. * *
|
||||
* *
|
||||
* OUTPUT: none. *
|
||||
* *
|
||||
* WARNINGS: * *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/08/2001 MML : Created. *
|
||||
*==========================================================================*/
|
||||
|
||||
char *Make_Current_Path_To ( char *filename, char *path )
|
||||
{
|
||||
char szPath [ _MAX_PATH ];
|
||||
char drive [ _MAX_DRIVE];
|
||||
char dir [ _MAX_DIR ];
|
||||
|
||||
strcpy( szPath, Args->Get_argv(0));
|
||||
_splitpath( szPath, drive, dir, NULL, NULL );
|
||||
_makepath( szPath, drive, dir, NULL, NULL );
|
||||
Path_Add_Back_Slash( szPath );
|
||||
strcat( szPath, filename );
|
||||
|
||||
if( path != NULL ) {
|
||||
strcpy( path, szPath );
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
wchar_t *Make_Current_Path_To ( wchar_t *filename, wchar_t *path )
|
||||
{
|
||||
wchar_t szPath [ _MAX_PATH ];
|
||||
wchar_t drive [ _MAX_DRIVE];
|
||||
wchar_t dir [ _MAX_DIR ];
|
||||
|
||||
wcscpy( szPath, (wchar_t *)Args->Get_argv(0));
|
||||
_wsplitpath( szPath, drive, dir, NULL, NULL );
|
||||
_wmakepath( szPath, drive, dir, NULL, NULL );
|
||||
Path_Add_Back_Slash( szPath );
|
||||
wcscat( szPath, filename );
|
||||
|
||||
if( path != NULL ) {
|
||||
wcscpy( path, szPath );
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Path_Add_Back_Slash -- Add a '\\' to the end of the path.
|
||||
*
|
||||
* INPUT: char * path -- Pointer to the string to be modified.
|
||||
*
|
||||
* OUTPUT: char * path
|
||||
*
|
||||
* WARNINGS: none
|
||||
*
|
||||
* HISTORY:
|
||||
* 08/14/1998 MML : Created.
|
||||
*============================================================================*/
|
||||
|
||||
char *Path_Add_Back_Slash ( char *path )
|
||||
{
|
||||
if ( path != NULL && *path != '\0' ) {
|
||||
if ( path[ strlen( path )-1 ] != '\\' ) {
|
||||
strcat( path, "\\" );
|
||||
}
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
wchar_t *Path_Add_Back_Slash ( wchar_t *path )
|
||||
{
|
||||
if ( path != NULL && *path != '\0' ) {
|
||||
if ( path[ wcslen( path )-1 ] != '\\' ) {
|
||||
wcscat( path, L"\\" );
|
||||
}
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Path_Remove_Back_Slash -- Remove a '\\' from the end of the path.
|
||||
*
|
||||
* INPUT: char * path -- Pointer to the string to be modified.
|
||||
*
|
||||
* OUTPUT: char * path
|
||||
*
|
||||
* WARNINGS: none
|
||||
*
|
||||
* HISTORY:
|
||||
* 08/14/1998 MML : Created.
|
||||
*============================================================================*/
|
||||
|
||||
char *Path_Remove_Back_Slash ( char *path )
|
||||
{
|
||||
if ( path != NULL && *path != '\0' ) {
|
||||
if ( path[ strlen( path )-1 ] == '\\' ) {
|
||||
path[ strlen( path )-1 ] = '\0';
|
||||
}
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
wchar_t *Path_Remove_Back_Slash ( wchar_t *path )
|
||||
{
|
||||
if ( path != NULL && *path != '\0' ) {
|
||||
if ( path[ wcslen( path )-1 ] == L'\\' ) {
|
||||
path[ wcslen( path )-1 ] = L'\0';
|
||||
}
|
||||
}
|
||||
return( path );
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Function: PlugInProductName */
|
||||
/* */
|
||||
/* Descrip: The function plugs the product name defined in */
|
||||
/* SdProductName() into %P found in the static message. */
|
||||
/* It will search for the first nMax controls only. */
|
||||
/* Misc: */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void PlugInProductName ( char *szString, char *szName )
|
||||
{
|
||||
int nCount, nMsgLength;
|
||||
char szTextBuf[ MAX_PATH ];
|
||||
char szOut[ MAX_PATH ];
|
||||
char szProduct[ MAX_PATH ];
|
||||
char * temp = NULL;
|
||||
char * next = NULL;
|
||||
|
||||
if ( szName == NULL || szName[0] == '\0' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Find the first appearance of "%P".
|
||||
//--------------------------------------------------------------------------
|
||||
strcpy( szProduct, szName );
|
||||
strcpy( szTextBuf, szString );
|
||||
nMsgLength = strlen( szTextBuf );
|
||||
nCount = 0;
|
||||
temp = strstr( szTextBuf, "%s" );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Substitute each "%P" with "%s". nStrReturn is the index
|
||||
// into the buffer where "%P" was found.
|
||||
//-------------------------------------------------------------
|
||||
while ( temp != NULL && nCount < 6) {
|
||||
next = temp+1;
|
||||
nCount = nCount + 1;
|
||||
temp = strstr( next, "%s" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Only support up to 5 product name per message.
|
||||
// Do the substitution of the product name and store in szOut.
|
||||
//-------------------------------------------------------------
|
||||
switch( nCount ) {
|
||||
case 1:
|
||||
sprintf( szOut, szTextBuf, szProduct );
|
||||
break;
|
||||
case 2:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct );
|
||||
break;
|
||||
case 3:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 4:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 5:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Replace szTextBuf with szOut.
|
||||
//-------------------------------------------------------------
|
||||
if ( nCount >= 1 ) {
|
||||
strcpy( szString, szOut );
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Function: PlugInProductName */
|
||||
/* */
|
||||
/* Descrip: The function plugs the product name defined in */
|
||||
/* SdProductName() into %P found in the static message. */
|
||||
/* It will search for the first nMax controls only. */
|
||||
/* Misc: */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void PlugInProductName( char *szString, int nName )
|
||||
{
|
||||
/*
|
||||
int nCount, nMsgLength;
|
||||
char szTextBuf[ MAX_PATH ];
|
||||
char szOut[ MAX_PATH ];
|
||||
char szProduct[ MAX_PATH ];
|
||||
char * temp = NULL;
|
||||
char * next = NULL;
|
||||
|
||||
if ( nName <= STRNONE ) {
|
||||
nName = STRNONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Find the first appearance of "%P".
|
||||
//-------------------------------------------------------------
|
||||
// LoadString( Main::hInstance, nName, szProduct, MAX_PATH );
|
||||
Locale_GetString( nName, szProduct );
|
||||
|
||||
strcpy( szTextBuf, szString );
|
||||
nMsgLength = strlen( szTextBuf );
|
||||
nCount = 0;
|
||||
temp = strstr( szTextBuf, "%s" );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Substitute each "%P" with "%s". nStrReturn is the index
|
||||
// into the buffer where "%P" was found.
|
||||
//-------------------------------------------------------------
|
||||
while ( temp != NULL && nCount < 6) {
|
||||
next = temp+1;
|
||||
nCount = nCount + 1;
|
||||
temp = strstr( next, "%s" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Only support up to 5 product name per message.
|
||||
// Do the substitution of the product name and store in szOut.
|
||||
//-------------------------------------------------------------
|
||||
switch( nCount ) {
|
||||
case 1:
|
||||
sprintf( szOut, szTextBuf, szProduct );
|
||||
break;
|
||||
case 2:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct );
|
||||
break;
|
||||
case 3:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 4:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 5:
|
||||
sprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Replace szTextBuf with szOut.
|
||||
//-------------------------------------------------------------
|
||||
if ( nCount >= 1 ) {
|
||||
strcpy( szString, szOut );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* Function: PlugInProductName */
|
||||
/* */
|
||||
/* Descrip: The function plugs the product name defined in */
|
||||
/* SdProductName() into %P found in the static message. */
|
||||
/* It will search for the first nMax controls only. */
|
||||
/* Misc: */
|
||||
/* */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
void PlugInProductName ( wchar_t *szString, const wchar_t *szName )
|
||||
{
|
||||
int nCount, nMsgLength;
|
||||
wchar_t szTextBuf[ MAX_PATH ];
|
||||
wchar_t szOut[ MAX_PATH ];
|
||||
wchar_t szProduct[ MAX_PATH ];
|
||||
wchar_t *temp = NULL;
|
||||
wchar_t *next = NULL;
|
||||
|
||||
if ( szName == NULL || szName[0] == '\0' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Find the first appearance of "%P".
|
||||
//--------------------------------------------------------------------------
|
||||
wcscpy( szProduct, szName );
|
||||
wcscpy( szTextBuf, szString );
|
||||
nMsgLength = wcslen( szTextBuf );
|
||||
nCount = 0;
|
||||
temp = wcsstr( szTextBuf, L"%s" );
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Substitute each "%P" with "%s". nStrReturn is the index
|
||||
// into the buffer where "%P" was found.
|
||||
//-------------------------------------------------------------
|
||||
while ( temp != NULL && nCount < 6) {
|
||||
next = temp+1;
|
||||
nCount = nCount + 1;
|
||||
temp = wcsstr( next, L"%s" );
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Only support up to 5 product name per message.
|
||||
// Do the substitution of the product name and store in szOut.
|
||||
//-------------------------------------------------------------
|
||||
switch( nCount ) {
|
||||
case 1:
|
||||
swprintf( szOut, szTextBuf, szProduct );
|
||||
break;
|
||||
case 2:
|
||||
swprintf( szOut, szTextBuf, szProduct, szProduct );
|
||||
break;
|
||||
case 3:
|
||||
swprintf( szOut, szTextBuf, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 4:
|
||||
swprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
case 5:
|
||||
swprintf( szOut, szTextBuf, szProduct, szProduct, szProduct, szProduct, szProduct, szProduct );
|
||||
break;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
// Replace szTextBuf with szOut.
|
||||
//-------------------------------------------------------------
|
||||
if ( nCount >= 1 ) {
|
||||
wcscpy( szString, szOut );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
75
Generals/Code/Tools/Autorun/Utils.h
Normal file
75
Generals/Code/Tools/Autorun/Utils.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***************************************************************************
|
||||
* *
|
||||
* Project Name : Setup *
|
||||
* *
|
||||
* File Name : UTILS.H *
|
||||
* *
|
||||
* Programmers: Maria del Mar McCready Legg *
|
||||
* *
|
||||
* Start Date : December 20, 1994 *
|
||||
* *
|
||||
* Last Update : April 06, 1998 [MML] *
|
||||
* *
|
||||
*-------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
#pragma once
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
** Swaps two objects.
|
||||
*/
|
||||
template<class T>
|
||||
void swap( T & left, T & right )
|
||||
{
|
||||
T temp;
|
||||
|
||||
temp = left;
|
||||
left = right;
|
||||
right = temp;
|
||||
}
|
||||
|
||||
|
||||
void Fix_Single_Ampersands ( LPSTR pszString, bool upper_case );
|
||||
void Fix_Single_Ampersands ( wchar_t *pszString, bool upper_case );
|
||||
//UnicodeString Fix_Single_Ampersands ( UnicodeString string, bool upper_case);
|
||||
void Fix_Double_Ampersands ( LPSTR string, bool upper_case );
|
||||
void * Load_Alloc_Data ( char *filename, long *filesize=0 );
|
||||
void * Load_File ( char *filename, long *filesize=0 );
|
||||
char * Make_Current_Path_To ( char *filename, char *path );
|
||||
wchar_t * Make_Current_Path_To ( wchar_t *filename, wchar_t *path );
|
||||
char * Path_Add_Back_Slash ( char *path );
|
||||
char * Path_Remove_Back_Slash ( char *path );
|
||||
wchar_t * Path_Add_Back_Slash ( wchar_t *path );
|
||||
wchar_t * Path_Remove_Back_Slash ( wchar_t *path );
|
||||
void PlugInProductName ( char *szString, int nName );
|
||||
void PlugInProductName ( char *szString, char *szName );
|
||||
void PlugInProductName ( wchar_t *szString, const wchar_t *szName );
|
||||
|
||||
|
||||
#endif
|
192
Generals/Code/Tools/Autorun/ViewHTML.cpp
Normal file
192
Generals/Code/Tools/Autorun/ViewHTML.cpp
Normal file
|
@ -0,0 +1,192 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/ViewHTML.cpp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 2/16/01 11:32a $
|
||||
* $Revision: 3 $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#pragma warning(disable : 4201 4310)
|
||||
#include <windows.h>
|
||||
|
||||
#include "ViewHTML.h"
|
||||
//#include "..\win.h"
|
||||
#include <stdio.h>
|
||||
//#include "debugprint.h"
|
||||
#include "wnd_file.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* NAME
|
||||
* ViewHTML
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Launch the default browser to view the specified URL
|
||||
*
|
||||
* INPUTS
|
||||
* URL - Website address
|
||||
* Wait - Wait for user to close browser (default = false)
|
||||
* Callback - User callback to invoke during wait (default = NULL callback)
|
||||
*
|
||||
* RESULT
|
||||
* Success - True if successful; otherwise false
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
bool ViewHTML(const char* url, bool wait, CallbackHook& callback)
|
||||
{
|
||||
// DebugPrint("ViewHTML()\n");
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ));
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("ViewHTML()" ));
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ));
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Just return if no URL specified
|
||||
//--------------------------------------------------------------------------
|
||||
if ((url == NULL) || (strlen(url) == 0))
|
||||
{
|
||||
// DebugPrint("***** No URL specified.\n");
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("***** No URL specified." ));
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Create unique temporary HTML filename
|
||||
//--------------------------------------------------------------------------
|
||||
char tempPath[MAX_PATH];
|
||||
GetWindowsDirectory(tempPath, MAX_PATH);
|
||||
|
||||
char filename1[MAX_PATH];
|
||||
char filename2[MAX_PATH];
|
||||
GetTempFileName(tempPath, "WS", 0, filename1);
|
||||
|
||||
strcpy( filename2, filename1 );
|
||||
char* extPtr = strrchr(filename2, '.');
|
||||
strcpy(extPtr, ".html");
|
||||
|
||||
// DebugPrint(filename);
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("filename = %s"), filename2 );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Create file
|
||||
//--------------------------------------------------------------------------
|
||||
HANDLE file = CreateFile(
|
||||
filename2,
|
||||
GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// DebugPrint("***** Unable to create temporary HTML file '%s'\n", filename);
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("***** Unable to create temporary HTML file '%s"), filename2 );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write generic contents
|
||||
const char* contents = "<title>ViewHTML</title>";
|
||||
DWORD written;
|
||||
WriteFile(file, contents, strlen(contents), &written, NULL);
|
||||
CloseHandle(file);
|
||||
|
||||
// Find the executable that can launch this file
|
||||
char exeName[MAX_PATH];
|
||||
HINSTANCE hInst = FindExecutable(filename2, NULL, exeName);
|
||||
|
||||
// Delete temporary file
|
||||
DeleteFile(filename2);
|
||||
DeleteFile(filename1);
|
||||
|
||||
if ((int)hInst <= 32)
|
||||
{
|
||||
// DebugPrint("***** Unable to find executable that will display HTML files.\n");
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("***** Unable to find executable that will display HTML files."));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Launch browser with specified URL
|
||||
char commandLine[MAX_PATH];
|
||||
sprintf(commandLine, "[open] %s", url);
|
||||
|
||||
STARTUPINFO startupInfo;
|
||||
memset(&startupInfo, 0, sizeof(startupInfo));
|
||||
startupInfo.cb = sizeof(startupInfo);
|
||||
|
||||
PROCESS_INFORMATION processInfo;
|
||||
|
||||
BOOL createSuccess = CreateProcess(
|
||||
exeName,
|
||||
commandLine,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
&startupInfo,
|
||||
&processInfo);
|
||||
|
||||
if (createSuccess == FALSE)
|
||||
{
|
||||
// DebugPrint("\t**** Failed to CreateProcess(%s, %s)\n", exeName, commandLine);
|
||||
Msg( __LINE__, TEXT(__FILE__), TEXT("\t**** Failed to CreateProcess(%s, %s)"), exeName, commandLine );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (wait == true)
|
||||
{
|
||||
WaitForInputIdle(processInfo.hProcess, 5000);
|
||||
|
||||
bool waiting = true;
|
||||
|
||||
while (waiting == true)
|
||||
{
|
||||
if (callback.DoCallback() == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(100);
|
||||
|
||||
DWORD exitCode;
|
||||
GetExitCodeProcess(processInfo.hProcess, &exitCode);
|
||||
|
||||
if (exitCode != STILL_ACTIVE)
|
||||
{
|
||||
waiting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
42
Generals/Code/Tools/Autorun/ViewHTML.h
Normal file
42
Generals/Code/Tools/Autorun/ViewHTML.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/ViewHTML.h $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 8/14/00 7:53p $
|
||||
* $Revision: 3 $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef VIEWHTML_H
|
||||
#define VIEWHTML_H
|
||||
|
||||
#include "CallbackHook.h"
|
||||
|
||||
bool ViewHTML(const char* url, bool wait = false, CallbackHook& callback = CallbackHook());
|
||||
|
||||
#endif // VIEWHTML_H
|
268
Generals/Code/Tools/Autorun/WSYS_File.cpp
Normal file
268
Generals/Code/Tools/Autorun/WSYS_File.cpp
Normal file
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO_
|
||||
//
|
||||
// File name: IO_File.cpp
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "wsys_File.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Externals
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Types
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Prototypes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//=================================================================
|
||||
// File::File
|
||||
//=================================================================
|
||||
|
||||
File::File()
|
||||
: m_open(FALSE),
|
||||
m_deleteOnClose(FALSE),
|
||||
m_access(NONE)
|
||||
{
|
||||
|
||||
setName("<no file>");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//=================================================================
|
||||
// File::~File
|
||||
//=================================================================
|
||||
|
||||
File::~File()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// File::open
|
||||
//=================================================================
|
||||
/**
|
||||
* Any derived open() members must first call File::open. If File::open
|
||||
* succeeds but the derived class's open failes then make sure to call
|
||||
* File::close() before returning.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
Bool File::open( const Char *filename, Int access )
|
||||
{
|
||||
if( m_open )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
setName( filename );
|
||||
|
||||
if( (access & ( TEXT | BINARY)) == ( TEXT | BINARY ))
|
||||
{
|
||||
// illegal access
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( !(access & (READ|APPEND)) )
|
||||
{
|
||||
access |= TRUNCATE;
|
||||
}
|
||||
|
||||
if ( (access & (READ|WRITE)) == 0 )
|
||||
{
|
||||
access = READ;
|
||||
}
|
||||
|
||||
if ( (access & (TEXT|BINARY)) == 0 )
|
||||
{
|
||||
access = BINARY;
|
||||
}
|
||||
|
||||
m_access = access;
|
||||
m_open = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// File::close
|
||||
//=================================================================
|
||||
/**
|
||||
* Must call File::close() for each successful File::open() call.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
void File::close( void )
|
||||
{
|
||||
if( m_open )
|
||||
{
|
||||
setName( "<no file>" );
|
||||
m_open = FALSE;
|
||||
if ( m_deleteOnClose )
|
||||
{
|
||||
delete this; // on special cases File object will delete itself when closing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// File::size
|
||||
//=================================================================
|
||||
/**
|
||||
* Default implementation of File::size. Derived classes can optimize
|
||||
* this member function.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
Int File::size( void )
|
||||
{
|
||||
Int pos = seek( 0, CURRENT );
|
||||
Int size = seek( 0, END );
|
||||
|
||||
seek( pos, START );
|
||||
|
||||
return size < 0 ? 0 : size;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// File::position
|
||||
//============================================================================
|
||||
|
||||
Int File::position( void )
|
||||
{
|
||||
return seek(0, CURRENT);
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// File::setName
|
||||
//=================================================================
|
||||
|
||||
void File::setName( const Char *name )
|
||||
{
|
||||
strncpy( m_name, name, sizeof( m_name ));
|
||||
m_name[sizeof(m_name)-1] = 0;
|
||||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// File::getName
|
||||
//=================================================================
|
||||
|
||||
Bool File::getName( Char *buffer, Int max )
|
||||
{
|
||||
if( buffer && max > 0 && (strlen( m_name ) < (UnsignedInt) max))
|
||||
{
|
||||
strcpy( buffer, m_name );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// File::printf
|
||||
//============================================================================
|
||||
|
||||
Bool File::printf ( const Char *format, ...)
|
||||
{
|
||||
Char buffer[10*1024];
|
||||
Int len;
|
||||
|
||||
if ( ! (m_access & TEXT ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start( args, format ); /* Initialize variable arguments. */
|
||||
len = vsprintf( buffer, format, args );
|
||||
va_end( args );
|
||||
|
||||
if ( len >= sizeof(buffer) )
|
||||
{
|
||||
// Big Problem
|
||||
assert( FALSE );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return (write ( buffer, len ) == len);
|
||||
}
|
||||
|
106
Generals/Code/Tools/Autorun/WSYS_FileSystem.cpp
Normal file
106
Generals/Code/Tools/Autorun/WSYS_FileSystem.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: IO_FileSystem.cpp
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "wsys_FileSystem.h"
|
||||
|
||||
#include "wsys_StdFileSystem.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Externals
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Types
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// TheFileSystem
|
||||
//===============================
|
||||
/**
|
||||
* This is the FileSystem's singleton class. All file access
|
||||
* should be through TheFileSystem, unless code needs to use an explicit
|
||||
* File or FileSystem derivative.
|
||||
*
|
||||
* Using TheFileSystem->open and File exclusively for file access, particularly
|
||||
* in library or modular code, allows applications to transparently implement
|
||||
* file access as they see fit. This is particularly important for code that
|
||||
* needs to be shared between applications, such as games and tools.
|
||||
*/
|
||||
//===============================
|
||||
|
||||
FileSystem *TheFileSystem = NULL;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Prototypes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
96
Generals/Code/Tools/Autorun/WSYS_FileSystem.h
Normal file
96
Generals/Code/Tools/Autorun/WSYS_FileSystem.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------=
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: wsys/FileSystem.h
|
||||
//
|
||||
// Created:
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WSYS_FILESYSTEM_H
|
||||
#define __WSYS_FILESYSTEM_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WSYS_FILE_H
|
||||
#include "wsys_file.h"
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// FileSystem
|
||||
//===============================
|
||||
/**
|
||||
* FileSystem is an interface class for creating specific FileSystem objects.
|
||||
*
|
||||
* A FileSystem object's implemenation decides what derivative of File object needs to be
|
||||
* created when FileSystem::Open() gets called.
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class FileSystem
|
||||
{
|
||||
protected:
|
||||
|
||||
public:
|
||||
|
||||
virtual ~FileSystem() {};
|
||||
virtual File* open( const Char *filename, Int access = 0 ) = NULL ; ///< opens a File interface to the specified file
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern FileSystem* TheFileSystem;
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#endif // __WSYS_FILESYSTEM_H
|
289
Generals/Code/Tools/Autorun/WSYS_RAMFile.cpp
Normal file
289
Generals/Code/Tools/Autorun/WSYS_RAMFile.cpp
Normal file
|
@ -0,0 +1,289 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: WSYS_RAMFile.cpp
|
||||
//
|
||||
// Created: 11/08/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "WSYS_FileSystem.h"
|
||||
#include "WSYS_RAMFile.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Externals
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Types
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Prototypes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::RAMFile
|
||||
//=================================================================
|
||||
|
||||
RAMFile::RAMFile()
|
||||
: m_size(0),
|
||||
m_data(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::~RAMFile
|
||||
//=================================================================
|
||||
|
||||
RAMFile::~RAMFile()
|
||||
{
|
||||
delete [] m_data;
|
||||
|
||||
File::close();
|
||||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::open
|
||||
//=================================================================
|
||||
/**
|
||||
* This function opens a file using the standard C open() call. Access flags
|
||||
* are mapped to the appropriate open flags. Returns true if file was opened
|
||||
* successfully.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
Bool RAMFile::open( const Char *filename, Int access )
|
||||
{
|
||||
File *file = TheFileSystem->open( filename, access );
|
||||
|
||||
if ( file == NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool result = open( file );
|
||||
|
||||
file->close();
|
||||
|
||||
return result;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
// RAMFile::open
|
||||
//============================================================================
|
||||
|
||||
Bool RAMFile::open( File *file )
|
||||
{
|
||||
if ( file == NULL )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Int access = file->getAccess();
|
||||
|
||||
if ( !File::open( file->getName(), access ))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// read whole file in to memory
|
||||
m_size = file->size();
|
||||
m_data = new char [ m_size ];
|
||||
|
||||
if ( m_data == NULL )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_size = file->read( m_data, m_size );
|
||||
|
||||
if ( m_size < 0 )
|
||||
{
|
||||
delete [] m_data;
|
||||
m_data = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_pos = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::close
|
||||
//=================================================================
|
||||
/**
|
||||
* Closes the current file if it is open.
|
||||
* Must call RAMFile::close() for each successful RAMFile::open() call.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
void RAMFile::close( void )
|
||||
{
|
||||
if ( m_data )
|
||||
{
|
||||
delete [] m_data;
|
||||
m_data = NULL;
|
||||
}
|
||||
|
||||
File::close();
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::read
|
||||
//=================================================================
|
||||
|
||||
Int RAMFile::read( void *buffer, Int bytes )
|
||||
{
|
||||
if( m_data == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
Int bytesLeft = m_size - m_pos ;
|
||||
|
||||
if ( bytes > bytesLeft )
|
||||
{
|
||||
bytes = bytesLeft;
|
||||
}
|
||||
|
||||
if ( bytes > 0 )
|
||||
{
|
||||
memcpy ( buffer, &m_data[m_pos], bytes );
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
m_pos += bytes;
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::write
|
||||
//=================================================================
|
||||
|
||||
Int RAMFile::write( void *buffer, Int bytes )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// RAMFile::seek
|
||||
//=================================================================
|
||||
|
||||
Int RAMFile::seek( Int pos, seekMode mode)
|
||||
{
|
||||
Int newPos;
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case START:
|
||||
newPos = pos;
|
||||
break;
|
||||
case CURRENT:
|
||||
newPos = m_pos + pos;
|
||||
break;
|
||||
case END:
|
||||
newPos = m_size - pos - 1;
|
||||
break;
|
||||
default:
|
||||
// bad seek mode
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( newPos < 0 )
|
||||
{
|
||||
newPos = 0;
|
||||
}
|
||||
else if ( newPos > m_size - 1 )
|
||||
{
|
||||
newPos = m_size - 1;
|
||||
}
|
||||
|
||||
m_pos = newPos;
|
||||
|
||||
return m_pos;
|
||||
|
||||
}
|
||||
|
100
Generals/Code/Tools/Autorun/WSYS_RAMFile.h
Normal file
100
Generals/Code/Tools/Autorun/WSYS_RAMFile.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------=
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: wsys/RAMFile.h
|
||||
//
|
||||
// Created: 11/08/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WSYS_RAMFILE_H
|
||||
#define __WSYS_RAMFILE_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "wsys_File.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// RAMFile
|
||||
//===============================
|
||||
/**
|
||||
* File abstraction for standard C file operators: open, close, lseek, read, write
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class RAMFile : public File
|
||||
{
|
||||
protected:
|
||||
|
||||
Char *m_data; ///< File data in memory
|
||||
Int m_pos; ///< current read position
|
||||
Int m_size; ///< size of file in memory
|
||||
|
||||
public:
|
||||
|
||||
RAMFile();
|
||||
virtual ~RAMFile();
|
||||
|
||||
|
||||
virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access
|
||||
virtual void close( void ); ///< Close the file
|
||||
virtual Int read( void *buffer, Int bytes ); ///< Read the specified number of bytes in to buffer: See File::read
|
||||
virtual Int write( void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write
|
||||
virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek
|
||||
|
||||
Bool open( File *file ); ///< Open file for fast RAM access
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // __WSYS_RAMFILE_H
|
256
Generals/Code/Tools/Autorun/WSYS_StdFile.cpp
Normal file
256
Generals/Code/Tools/Autorun/WSYS_StdFile.cpp
Normal file
|
@ -0,0 +1,256 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO_
|
||||
//
|
||||
// File name: IO_StdFile.cpp
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "wsys_StdFile.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Externals
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Types
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Prototypes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//=================================================================
|
||||
// StdFile::StdFile
|
||||
//=================================================================
|
||||
|
||||
StdFile::StdFile()
|
||||
: m_handle(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//=================================================================
|
||||
// StdFile::~StdFile
|
||||
//=================================================================
|
||||
|
||||
StdFile::~StdFile()
|
||||
{
|
||||
if( m_handle != -1 )
|
||||
{
|
||||
_close( m_handle );
|
||||
m_handle = -1;
|
||||
}
|
||||
|
||||
File::close();
|
||||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFile::open
|
||||
//=================================================================
|
||||
/**
|
||||
* This function opens a file using the standard C open() call. Access flags
|
||||
* are mapped to the appropriate open flags. Returns true if file was opened
|
||||
* successfully.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
Bool StdFile::open( const Char *filename, Int access )
|
||||
{
|
||||
if( !File::open( filename, access) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* here we translate WSYS file access to the std C equivalent */
|
||||
|
||||
int flags = 0;
|
||||
|
||||
if(m_access & CREATE) flags |= _O_CREAT;
|
||||
if(m_access & TRUNCATE) flags |= _O_TRUNC;
|
||||
if(m_access & APPEND) flags |= _O_APPEND;
|
||||
if(m_access & TEXT) flags |= _O_TEXT;
|
||||
if(m_access & BINARY) flags |= _O_BINARY;
|
||||
|
||||
if((m_access & READWRITE )== READWRITE )
|
||||
{
|
||||
flags |= _O_RDWR;
|
||||
}
|
||||
else if(m_access & WRITE)
|
||||
{
|
||||
flags |= _O_WRONLY;
|
||||
}
|
||||
else
|
||||
flags |= _O_RDONLY;
|
||||
|
||||
m_handle = _open( filename, flags , _S_IREAD | _S_IWRITE);
|
||||
|
||||
if( m_handle == -1 )
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ( m_access & APPEND )
|
||||
{
|
||||
if ( seek ( 0, END ) < 0 )
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
|
||||
close();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFile::close
|
||||
//=================================================================
|
||||
/**
|
||||
* Closes the current file if it is open.
|
||||
* Must call StdFile::close() for each successful StdFile::open() call.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
void StdFile::close( void )
|
||||
{
|
||||
File::close();
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFile::read
|
||||
//=================================================================
|
||||
|
||||
Int StdFile::read( void *buffer, Int bytes )
|
||||
{
|
||||
if( !m_open || !buffer )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _read( m_handle, buffer, bytes );
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFile::write
|
||||
//=================================================================
|
||||
|
||||
Int StdFile::write( void *buffer, Int bytes )
|
||||
{
|
||||
|
||||
if( !m_open || !buffer )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _write( m_handle, buffer, bytes );
|
||||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFile::seek
|
||||
//=================================================================
|
||||
|
||||
Int StdFile::seek( Int pos, seekMode mode)
|
||||
{
|
||||
int lmode;
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case START:
|
||||
lmode = SEEK_SET;
|
||||
break;
|
||||
case CURRENT:
|
||||
lmode = SEEK_CUR;
|
||||
break;
|
||||
case END:
|
||||
lmode = SEEK_END;
|
||||
break;
|
||||
default:
|
||||
// bad seek mode
|
||||
return -1;
|
||||
}
|
||||
|
||||
return _lseek( m_handle, pos, lmode );
|
||||
|
||||
}
|
||||
|
97
Generals/Code/Tools/Autorun/WSYS_StdFile.h
Normal file
97
Generals/Code/Tools/Autorun/WSYS_StdFile.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------=
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: wsys/StdFile.h
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WSYS_STDFILE_H
|
||||
#define __WSYS_STDFILE_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "wsys_File.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// StdFile
|
||||
//===============================
|
||||
/**
|
||||
* File abstraction for standard C file operators: open, close, lseek, read, write
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class StdFile : public File
|
||||
{
|
||||
protected:
|
||||
|
||||
int m_handle; ///< Std C file handle
|
||||
|
||||
public:
|
||||
|
||||
StdFile();
|
||||
virtual ~StdFile();
|
||||
|
||||
|
||||
virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a fioe for access
|
||||
virtual void close( void ); ///< Close the file
|
||||
virtual Int read( void *buffer, Int bytes ); ///< Read the specified number of bytes in to buffer: See File::read
|
||||
virtual Int write( void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write
|
||||
virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif // __WSYS_STDFILE_H
|
122
Generals/Code/Tools/Autorun/WSYS_StdFileSystem.cpp
Normal file
122
Generals/Code/Tools/Autorun/WSYS_StdFileSystem.cpp
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: IO_StdFileSystem.cpp
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "wsys_StdFileSystem.h"
|
||||
#include "wsys_StdFile.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Externals
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Types
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Data
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Prototypes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Public Functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//=================================================================
|
||||
// StdFileSystem::~StdFileSystem
|
||||
//=================================================================
|
||||
|
||||
StdFileSystem::~StdFileSystem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=================================================================
|
||||
// StdFileSystem::open
|
||||
//=================================================================
|
||||
/**
|
||||
* This simply creates a StdFile object and calls its open function.
|
||||
*/
|
||||
//=================================================================
|
||||
|
||||
File* StdFileSystem::open( const Char *filename, Int access )
|
||||
{
|
||||
StdFile *file = new StdFile();
|
||||
|
||||
if( file->open( filename, access ))
|
||||
{
|
||||
file->deleteOnClose(); // File object not created by the user so delete it when the user is finished with it
|
||||
}
|
||||
else
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
}
|
||||
|
||||
return (File*) file;
|
||||
}
|
92
Generals/Code/Tools/Autorun/WSYS_StdFileSystem.h
Normal file
92
Generals/Code/Tools/Autorun/WSYS_StdFileSystem.h
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------=
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: wsys/StdFileSystem.h
|
||||
//
|
||||
// Created:
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WSYS_STDFILESYSTEM_H
|
||||
#define __WSYS_STDFILESYSTEM_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __WSYS_FILE_H
|
||||
#include "wsys_File.h"
|
||||
#endif
|
||||
|
||||
#ifndef __WSYS_FILESYSTEM_H
|
||||
#include "wsys_FileSystem.h"
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//===============================
|
||||
// StdFileSystem
|
||||
//===============================
|
||||
/**
|
||||
* FileSystem that maps directly to StdFile files.
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class StdFileSystem : public FileSystem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~StdFileSystem();
|
||||
virtual File* open( const Char *filename, Int access = 0 ); ///< Creates a StdFile object and opens the file with it: See FileSystem::open
|
||||
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
#endif // __WSYS_STDFILESYSTEM_H
|
167
Generals/Code/Tools/Autorun/WSYS_file.h
Normal file
167
Generals/Code/Tools/Autorun/WSYS_file.h
Normal file
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------------=
|
||||
//
|
||||
// Westwood Studios Pacific.
|
||||
//
|
||||
// Confidential Information
|
||||
// Copyright(C) 2001 - All Rights Reserved
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
//
|
||||
// Project: WSYS Library
|
||||
//
|
||||
// Module: IO
|
||||
//
|
||||
// File name: wsys/File.h
|
||||
//
|
||||
// Created: 4/23/01
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __WSYS_FILE_H
|
||||
#define __WSYS_FILE_H
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#include "lib/basetype.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Forward References
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Type Defines
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define IO_MAX_PATH (2*1024) ///< Maximum allowable path legnth
|
||||
|
||||
//===============================
|
||||
// File
|
||||
//===============================
|
||||
/**
|
||||
* File is an interface class for basic file operations.
|
||||
*
|
||||
* All code should use the File class and not its derivatives, unless
|
||||
* absolutely necessary. Also FS::Open should be used to create File objects and open files.
|
||||
*/
|
||||
//===============================
|
||||
|
||||
class File
|
||||
{
|
||||
friend class FileSystem;
|
||||
|
||||
public:
|
||||
|
||||
enum access
|
||||
{
|
||||
NONE = 0x00000000,
|
||||
READ = 0x00000001, ///< Access file for reading
|
||||
WRITE = 0x00000002, ///< Access file for writing
|
||||
APPEND = 0x00000004, ///< Seek to end of file on open
|
||||
CREATE = 0x00000008, ///< Create file if it does not exist
|
||||
TRUNCATE = 0x00000010, ///< Delete all data in file when opened
|
||||
TEXT = 0x00000020, ///< Access file as text data
|
||||
BINARY = 0x00000040, ///< Access file as binary data
|
||||
READWRITE = (READ | WRITE),
|
||||
NEW = 0x00000080 ///< Only create file if it does not exist
|
||||
};
|
||||
|
||||
enum seekMode
|
||||
{
|
||||
START, ///< Seek position is relative to start of file
|
||||
CURRENT, ///< Seek position is relative to current file position
|
||||
END ///< Seek position is relative from the end of the file
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Char m_name[IO_MAX_PATH+1]; ///< Stores file name
|
||||
Bool m_open; ///< Has the file been opened
|
||||
Bool m_deleteOnClose; ///< delete File object on close()
|
||||
Int m_access; ///< How the file was opened
|
||||
|
||||
|
||||
File(); ///< This class can only used as a base class
|
||||
virtual ~File();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access
|
||||
virtual void close( void ); ///< Close the file !!! File object no longer valid after this call !!!
|
||||
|
||||
virtual Int read( void *buffer, Int bytes ) = NULL ; /**< Read the specified number of bytes from the file in to the
|
||||
* memory pointed at by buffer. Returns the number of bytes read.
|
||||
* Returns -1 if an error occured.
|
||||
*/
|
||||
virtual Int write( void *buffer, Int bytes ) = NULL ; /**< Write the specified number of bytes from the
|
||||
* memory pointed at by buffer to the file. Returns the number of bytes written.
|
||||
* Returns -1 if an error occured.
|
||||
*/
|
||||
virtual Int seek( Int bytes, seekMode mode = CURRENT ) = NULL; /**< Sets the file position of the next read/write operation. Returns the new file
|
||||
* position as the number of bytes from the start of the file.
|
||||
* Returns -1 if an error occured.
|
||||
*
|
||||
* seekMode determines how the seek is done:
|
||||
*
|
||||
* START : means seek to the specified number of bytes from the start of the file
|
||||
* CURRENT: means seek the specified the number of bytes from the current file position
|
||||
* END: means seek the specified number of bytes back from the end of the file
|
||||
*/
|
||||
virtual Bool printf ( const Char *format, ...); ///< Prints formated string to text file
|
||||
virtual Int size( void ); ///< Returns the size of the file
|
||||
virtual Int position( void ); ///< Returns the current read/write position
|
||||
|
||||
|
||||
void setName( const Char *name ); ///< Set the name of the file
|
||||
Char* getName( void ); ///< Returns a pointer to the name of the file
|
||||
Bool getName( Char *buffer, Int max ); ///< Copies the name of the file to the buffer
|
||||
Int getAccess( void ); ///< Returns file's access flags
|
||||
|
||||
void deleteOnClose ( void ); ///< Causes the File object to delete itself when it closes
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Inlining
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
inline Char* File::getName( void ) { return m_name;};
|
||||
inline Int File::getAccess( void ) { return m_access;};
|
||||
inline void File::deleteOnClose( void ) { m_deleteOnClose = TRUE;};
|
||||
|
||||
|
||||
|
||||
// include FileSystem.h as it will be used alot with File.h
|
||||
//#include "wsys/FileSystem.h"
|
||||
|
||||
|
||||
#endif // __WSYS_FILE_H
|
350
Generals/Code/Tools/Autorun/WinFix.CPP
Normal file
350
Generals/Code/Tools/Autorun/WinFix.CPP
Normal file
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer *
|
||||
* *
|
||||
* $Archive:: /Renegade Setup/Autorun/WinFix.CPP $*
|
||||
* *
|
||||
* $Author:: Maria_l $*
|
||||
* *
|
||||
* $Modtime:: 11/15/01 10:44a $*
|
||||
* *
|
||||
* $Revision:: 6 $*
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* Make_Identifier -- Creates a temporary string identifer. *
|
||||
* WindowsVersionInfo::WindowsVersionInfo -- Windows Version Info constructor. *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#pragma hdrstop
|
||||
|
||||
//#include <commctrl.h>
|
||||
//#include <winuser.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "winfix.h"
|
||||
#include "wnd_file.h"
|
||||
|
||||
/***************************************************************************
|
||||
** Windows Version Info global object.
|
||||
*/
|
||||
WindowsVersionInfo WinVersion;
|
||||
|
||||
|
||||
|
||||
/***********************************************************************************************
|
||||
* WindowsVersionInfo::WindowsVersionInfo -- Windows Version Info constructor. *
|
||||
* *
|
||||
* This routine will examine the system to determine the OS, version, and patch level of *
|
||||
* the current OS. *
|
||||
* *
|
||||
* INPUT: none *
|
||||
* *
|
||||
* OUTPUT: none *
|
||||
* *
|
||||
* WARNINGS: Don't try and use this class until after WinMain, because it won't be *
|
||||
* initialized until all the global objects have been constructed. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 04/09/98 jdl : Created. *
|
||||
*=============================================================================================*/
|
||||
WindowsVersionInfo::WindowsVersionInfo(void) :
|
||||
WindowsVersion(0),
|
||||
MajorVersionNumber(0),
|
||||
MinorVersionNumber(0),
|
||||
RunningOSR2(0),
|
||||
BuildNumber(0),
|
||||
IsWin9x(false),
|
||||
IsWin95(false),
|
||||
IsWin98(false),
|
||||
IsWin2000(false),
|
||||
IsWinNT(false),
|
||||
IsWinXP(false)
|
||||
{
|
||||
OSVERSIONINFO version_info;
|
||||
|
||||
VersionName[0] = '\0';
|
||||
AdditionalInfo[0] = '\0';
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Start recording messages.
|
||||
//--------------------------------------------------------------------------
|
||||
Delete_Msg_File();
|
||||
Msg( __LINE__, __FILE__, "----------------------------------------------", NULL );
|
||||
Msg( __LINE__, __FILE__, "------------------ Setup -----------------", NULL );
|
||||
Msg( __LINE__, __FILE__, "----------------------------------------------", NULL );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Get the version info from the OS.
|
||||
//
|
||||
// typedef struct _OSVERSIONINFO{
|
||||
// DWORD dwOSVersionInfoSize;
|
||||
// DWORD dwMajorVersion;
|
||||
// DWORD dwMinorVersion;
|
||||
// DWORD dwBuildNumber;
|
||||
// DWORD dwPlatformId;
|
||||
// TCHAR szCSDVersion[ 128 ];
|
||||
// } OSVERSIONINFO;
|
||||
//
|
||||
// typedef struct _OSVERSIONINFOEX {
|
||||
// DWORD dwOSVersionInfoSize;
|
||||
// DWORD dwMajorVersion;
|
||||
// DWORD dwMinorVersion;
|
||||
// DWORD dwBuildNumber;
|
||||
// DWORD dwPlatformId;
|
||||
// TCHAR szCSDVersion[ 128 ];
|
||||
// WORD wServicePackMajor;
|
||||
// WORD wServicePackMinor;
|
||||
// WORD wSuiteMask;
|
||||
// BYTE wProductType;
|
||||
// BYTE wReserved;
|
||||
// } OSVERSIONINFOEX, *POSVERSIONINFOEX, *LPOSVERSIONINFOEX;
|
||||
//--------------------------------------------------------------------------
|
||||
ZeroMemory( &version_info, sizeof( version_info ));
|
||||
version_info.dwOSVersionInfoSize = sizeof( version_info );
|
||||
|
||||
int result = GetVersionEx( &version_info );
|
||||
assert( result != 0 );
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Save the major/minor version numbers
|
||||
//--------------------------------------------------------------------------
|
||||
MajorVersionNumber = (int)version_info.dwMajorVersion;
|
||||
MinorVersionNumber = (int)version_info.dwMinorVersion;
|
||||
WindowsVersion = ( MajorVersionNumber * 100 ) + MinorVersionNumber;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Save the build number
|
||||
//--------------------------------------------------------------------------
|
||||
BuildNumber = (int)version_info.dwBuildNumber;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Check for Win9x
|
||||
//--------------------------------------------------------------------------
|
||||
if ( version_info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) {
|
||||
|
||||
IsWin9x = true;
|
||||
|
||||
if ( MajorVersionNumber == 4 && MinorVersionNumber == 0 ) {
|
||||
IsWin95 = true;
|
||||
}
|
||||
if (( MajorVersionNumber > 4 ) || (( MajorVersionNumber == 4 ) && ( MinorVersionNumber > 0 ))) {
|
||||
IsWin98 = true;
|
||||
}
|
||||
|
||||
if ( LOWORD( version_info.dwPlatformId ) > 1000 ) {
|
||||
RunningOSR2 = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Check for WinNT
|
||||
//--------------------------------------------------------------------------
|
||||
if ( version_info.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
|
||||
|
||||
IsWinNT = true;
|
||||
|
||||
if (( MajorVersionNumber >= 5 ) && ( MinorVersionNumber >= 1 )) {
|
||||
IsWinXP = true;
|
||||
// if ( version_info.wSuiteMask == VER_SUITE_PERSONAL ) {
|
||||
// }
|
||||
} else if (( MajorVersionNumber == 5 ) && ( MinorVersionNumber == 0 )) {
|
||||
IsWin2000 = true;
|
||||
}
|
||||
|
||||
// if( bOsVersionInfoEx )
|
||||
// {
|
||||
// if ( osvi.wProductType == VER_NT_WORKSTATION )
|
||||
// printf ( "Professional " );
|
||||
//
|
||||
// if ( osvi.wProductType == VER_NT_SERVER )
|
||||
// printf ( "Server " );
|
||||
|
||||
// } else {
|
||||
|
||||
#if( _DEBUG )
|
||||
HKEY hKey;
|
||||
char szProductType[80];
|
||||
DWORD dwBufLen;
|
||||
|
||||
RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey );
|
||||
RegQueryValueEx( hKey, "ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen);
|
||||
RegCloseKey( hKey );
|
||||
|
||||
if ( lstrcmpi( "WINNT", szProductType) == 0 )
|
||||
Msg( __LINE__, __FILE__, "WinNT Workstation." );
|
||||
if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
|
||||
Msg( __LINE__, __FILE__, "WinNT Server." );
|
||||
#endif
|
||||
// }
|
||||
}
|
||||
|
||||
#ifdef DEV_VERSION
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// For developmental versions, just use the major & minor version #'s
|
||||
//--------------------------------------------------------------------------
|
||||
sprintf( VersionName, "%x.%x", MajorVersionNumber, MinorVersionNumber );
|
||||
|
||||
#else
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// For final versions, trim 0's off the minor version
|
||||
//--------------------------------------------------------------------------
|
||||
unsigned short adjusted_minor;
|
||||
int i;
|
||||
|
||||
adjusted_minor = MinorVersionNumber;
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((adjusted_minor & 0x000f) != 0) {
|
||||
break;
|
||||
}
|
||||
adjusted_minor >>= 4;
|
||||
}
|
||||
sprintf( VersionName, "%x.%x", MajorVersionNumber, adjusted_minor );
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Save off the additional version information string
|
||||
// (used to indicated additional info or patch level, i.e. for NT 4.0 SP3
|
||||
// it would contain the string 'Service Pack 3')
|
||||
//--------------------------------------------------------------------------
|
||||
strncpy( AdditionalInfo, version_info.szCSDVersion, sizeof(AdditionalInfo) - 1 );
|
||||
AdditionalInfo[sizeof(AdditionalInfo) - 1] = '\x0';
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Send all info found to the debug output file.
|
||||
//--------------------------------------------------------------------------
|
||||
#if ( _DEBUG )
|
||||
Msg( __LINE__, __FILE__, "MajorVersionNumber = %d", MajorVersionNumber );
|
||||
Msg( __LINE__, __FILE__, "MinorVersionNumber = %d", MinorVersionNumber );
|
||||
Msg( __LINE__, __FILE__, "WindowsVersion = %d", WindowsVersion );
|
||||
Msg( __LINE__, __FILE__, "BuildNumber = %d", BuildNumber );
|
||||
Msg( __LINE__, __FILE__, "IsWin9x = %d", IsWin9x );
|
||||
Msg( __LINE__, __FILE__, "IsWin95 = %d", IsWin95 );
|
||||
Msg( __LINE__, __FILE__, "IsWin98 = %d", IsWin98 );
|
||||
Msg( __LINE__, __FILE__, "IsWin2000 = %d", IsWin2000 );
|
||||
Msg( __LINE__, __FILE__, "RunningOSR2 = %d", RunningOSR2 );
|
||||
Msg( __LINE__, __FILE__, "IsWinNT = %d", IsWinNT );
|
||||
Msg( __LINE__, __FILE__, "AdditionalInfo = %s", AdditionalInfo );
|
||||
Msg( __LINE__, __FILE__, "VersionName = %s", VersionName );
|
||||
#endif
|
||||
}
|
||||
|
||||
/***********************************************************************************************
|
||||
* WindowsVersionInfo::Version_String -- Get the version number in human readable form *
|
||||
* *
|
||||
* INPUT: Nothing *
|
||||
* *
|
||||
* OUTPUT: Ptr to string containing version info *
|
||||
* *
|
||||
* WARNINGS: None *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 3/30/99 10:29PM ST : Created *
|
||||
*=============================================================================================*/
|
||||
char *WindowsVersionInfo::Version_String(void)
|
||||
{
|
||||
static char _ver95[] = {"Windows 95 "};
|
||||
static char _ver98[] = {"Windows 98 "};
|
||||
static char _verNT4[] = {"Windows NT 4 "};
|
||||
static char _verNT5[] = {"Windows 2000 "};
|
||||
static char _verXP[] = {"Windows XP "};
|
||||
static char _unknown[] = {"Unknown "};
|
||||
|
||||
static char version[256];
|
||||
|
||||
if (Is_Win95()) {
|
||||
strcpy (version, _ver95);
|
||||
}
|
||||
|
||||
if (Is_Win98()) {
|
||||
strcpy (version, _ver98);
|
||||
}
|
||||
|
||||
if (Is_WinNT()) {
|
||||
strcpy (version, _verNT4);
|
||||
}
|
||||
|
||||
if (Is_WinNT5() || Is_Win_2000()) {
|
||||
strcpy (version, _verNT5);
|
||||
}
|
||||
|
||||
if (Is_Win_XP()) {
|
||||
strcpy (version, _verXP);
|
||||
}
|
||||
|
||||
strcat (version, AdditionalInfo);
|
||||
|
||||
return (version);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* WindowsVersionClass::Version_Name -- returns version # as char string *
|
||||
* *
|
||||
* INPUT: *
|
||||
* none. *
|
||||
* *
|
||||
* OUTPUT: *
|
||||
* ptr to name *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* none. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/30/1995 BRR : Created. *
|
||||
*=========================================================================*/
|
||||
|
||||
char * WindowsVersionInfo::Version_Name(void)
|
||||
{
|
||||
return ( VersionName );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* WindowsVersionClass::Meets_Minimum_Version_Requirements *
|
||||
* *
|
||||
* INPUT: *
|
||||
* none. *
|
||||
* *
|
||||
* OUTPUT: *
|
||||
* ptr to name *
|
||||
* *
|
||||
* WARNINGS: *
|
||||
* none. *
|
||||
* *
|
||||
* HISTORY: *
|
||||
* 10/30/1995 BRR : Created. *
|
||||
*==========================================================================*/
|
||||
|
||||
bool WindowsVersionInfo::Meets_Minimum_Version_Requirements ( void )
|
||||
{
|
||||
// return(( !IsWin95 && ( Version() >= 400 ))? true : false );
|
||||
return(( Version() >= 400 )? true : false );
|
||||
}
|
||||
|
||||
|
||||
|
149
Generals/Code/Tools/Autorun/WinFix.H
Normal file
149
Generals/Code/Tools/Autorun/WinFix.H
Normal file
|
@ -0,0 +1,149 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/***********************************************************************************************
|
||||
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
|
||||
***********************************************************************************************
|
||||
* *
|
||||
* Project Name : Command & Conquer *
|
||||
* *
|
||||
* $Archive:: /Renegade Setup/Autorun/WinFix.H $*
|
||||
* *
|
||||
* $Author:: Maria_l $*
|
||||
* *
|
||||
* $Modtime:: 11/07/01 5:57p $*
|
||||
* *
|
||||
* $Revision:: 6 $*
|
||||
* *
|
||||
*---------------------------------------------------------------------------------------------*
|
||||
* Functions: *
|
||||
* WindowsVersionInfo::Major -- Get the major version of the OS *
|
||||
* WindowsVersionInfo::Minor -- Get the minor version of the OS *
|
||||
* WindowsVersionInfo::Build -- Get the build level of the OS *
|
||||
* WindowsVersionInfo::Info -- Get additional system information *
|
||||
* WindowsVersionInfo::Is_Win9x -- Determine if we are running on a non-NT system. *
|
||||
* WindowsVersionInfo::Is_Win95 -- Determine if we are running on a Win95 system. *
|
||||
* WindowsVersionInfo::Is_Win98 -- Determine if we are running on a Win98 system. *
|
||||
* WindowsVersionInfo::Is_WinNT -- Determine if we are running on an NT system. *
|
||||
* WindowsVersionInfo::Is_WinNT5 -- Determine if we are running on an NT 5 system. *
|
||||
* WindowsVersionInfo::Version -- *
|
||||
* WindowsVersionInfo::IsOSR2Release -- *
|
||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef WINFIX_H
|
||||
#define WINFIX_H
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
** Windows Version Information class. This is a global object that is used to
|
||||
** store information about the specific OS that we are running under. This can
|
||||
** be used to make special allowances for differences between OS's, such as when
|
||||
** using the registry, or trying to work around a limitaion of a particular OS
|
||||
** (their APIs are slightly different...)
|
||||
**-----------------------------------------------------------------------------*/
|
||||
class WindowsVersionInfo
|
||||
{
|
||||
public:
|
||||
WindowsVersionInfo (void);
|
||||
~WindowsVersionInfo (void) {}
|
||||
|
||||
int Major ( void ) const { return( MajorVersionNumber ); }
|
||||
int Minor ( void ) const { return( MinorVersionNumber ); }
|
||||
int Build ( void ) const { return( BuildNumber ); }
|
||||
bool Is_Win9x ( void ) const { return( IsWin9x ); } // Win 9x
|
||||
bool Is_Win95 ( void ) const { return( IsWin95 ); } // Win 95
|
||||
bool Is_Win98 ( void ) const { return( IsWin98 ); } // Win 98
|
||||
bool Is_WinNT ( void ) const { return( IsWinNT ); } // Win NT
|
||||
bool Is_WinNT4 ( void ) const { return( IsWinNT && MajorVersionNumber == 4 ); } // Win NT
|
||||
bool Is_WinNT5 ( void ) const { return( IsWinNT && MajorVersionNumber == 5 ); } // Win NT
|
||||
bool Is_Win_2000 ( void ) const { return( IsWin2000 ); } // Win 2000
|
||||
bool Is_Win_XP ( void ) const { return( IsWinXP ); } // Win XP
|
||||
int Version ( void ) const { return( WindowsVersion ); }
|
||||
int IsOSR2Release ( void ) const { return( RunningOSR2 ); }
|
||||
const char * Info ( void ) const { return( &AdditionalInfo[0] ); }
|
||||
char * Version_String ( void );
|
||||
char * Version_Name ( void );
|
||||
bool Meets_Minimum_Version_Requirements ( void );
|
||||
|
||||
private:
|
||||
/*-----------------------------------------------------------------------
|
||||
** Major version number; i.e. for 4.10.1721 this would be '4'
|
||||
*/
|
||||
int MajorVersionNumber;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Minor version number; i.e. for 4.10.1721 this would be '10'
|
||||
*/
|
||||
int MinorVersionNumber;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Version number expressed as a DWORD; i.e. for 4.10 this would be '410'
|
||||
*/
|
||||
int WindowsVersion;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Build number; i.e. for 4.10.1721 this would be '1721'
|
||||
*/
|
||||
int BuildNumber;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Is the system running OSR 2 or later release of Windows95.
|
||||
*/
|
||||
int RunningOSR2;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Additional Info; i.e. for NT 4.0 with SP3, this would be
|
||||
** the string 'Service Pack 3'
|
||||
*/
|
||||
char AdditionalInfo[128];
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Windows 9x flag; true if running on non-NT system
|
||||
*/
|
||||
bool IsWin9x;
|
||||
bool IsWin95;
|
||||
bool IsWin98;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Windows NT flag; true if running on Windows NT system
|
||||
*/
|
||||
bool IsWinNT;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Windows 2000 (Formerly Windows NT 5.0)
|
||||
** As you've no doubt heard by now, Windows NT 5.0 has been officially
|
||||
** christened "Windows 2000."
|
||||
*/
|
||||
bool IsWin2000;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** Windows XP flag; true if running on Windows NT system
|
||||
*/
|
||||
bool IsWinXP;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
** This array is used for formatting the version # as a string
|
||||
*/
|
||||
char VersionName[30];
|
||||
};
|
||||
|
||||
extern WindowsVersionInfo WinVersion;
|
||||
|
||||
#endif
|
216
Generals/Code/Tools/Autorun/Wnd_File.h
Normal file
216
Generals/Code/Tools/Autorun/Wnd_File.h
Normal file
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//****************************************************************************
|
||||
// C O N F I D E N T I A L -- W E S T W O O D S T U D I O S
|
||||
//****************************************************************************
|
||||
//
|
||||
// Project name: Blade Runner CD-ROM Windows 95
|
||||
//
|
||||
// File name: WND_FILE.H
|
||||
//
|
||||
// Source code: WND_FILE.CPP
|
||||
//
|
||||
// Compatibility: Microsoft Visual C++ 4.0
|
||||
// Borland C++ 5.0
|
||||
// Watcom C++ 10.6
|
||||
//
|
||||
// Start Date: See comments in version control log
|
||||
// Last Update: See comments in version control log
|
||||
//
|
||||
// Programmer(s): Michael Legg
|
||||
// Mike Grayford
|
||||
// James McNeill
|
||||
//
|
||||
//****************************************************************************
|
||||
#pragma once
|
||||
|
||||
#ifndef WND_FILE_H
|
||||
#define WND_FILE_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// include files...
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define BOOL int
|
||||
#define ASSERT(x) assert(x)
|
||||
#define VERIFY(X) assert(X)
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// defines...
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// it's one or the other!
|
||||
//
|
||||
#define SUPPORT_STREAMS TRUE // Normally this!
|
||||
#define SUPPORT_HANDLES FALSE // This is a test!
|
||||
|
||||
#define MODE_READ_ONLY 0
|
||||
#define MODE_WRITE_ONLY 1
|
||||
#define MODE_READ_AND_WRITE 2
|
||||
|
||||
#define MODE_WRITE_TRUNCATE MODE_WRITE_ONLY
|
||||
#define MODE_WRITE_APPEND 3
|
||||
#define MODE_WRITE_UPDATE 4
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
// #define INVALID_FILE_HANDLE -1
|
||||
#define INVALID_FILE_HANDLE INVALID_HANDLE_VALUE
|
||||
#define MAX_PATH_SIZE _MAX_PATH
|
||||
|
||||
|
||||
#define STRING_IT(a) #a
|
||||
#define TOKEN_IT(a) STRING_IT(,##a)
|
||||
#define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a)
|
||||
|
||||
//#pragma MESSAGE("What does it do?")
|
||||
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
void __cdecl Msg( int line, char *file, char *fmt, ... );
|
||||
void __cdecl Msg( int line, char *filename, wchar_t *fmt, unsigned int codepage=1252, ... );
|
||||
void Delete_Msg_File( void );
|
||||
#else
|
||||
#define Msg
|
||||
#define Delete_Msg_File()
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// file class definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class StandardFileClass
|
||||
{
|
||||
public:
|
||||
|
||||
//
|
||||
// public class functions...
|
||||
//
|
||||
StandardFileClass();
|
||||
~StandardFileClass();
|
||||
bool Open ( const char *file_name, int open_mode );
|
||||
bool Close ( void );
|
||||
int Read ( void *buffer, unsigned long int bytes_to_read );
|
||||
int Write ( void *buffer, unsigned long int bytes_to_write );
|
||||
bool Seek ( int distance, int seek_file_position );
|
||||
int Tell ( void );
|
||||
int Query_Size ( void );
|
||||
bool Query_Open ( void );
|
||||
char * Query_Name_String ( void );
|
||||
int End_Of_File ( void );
|
||||
int Flush ( void );
|
||||
|
||||
#if( SUPPORT_STREAMS )
|
||||
FILE *Query_File_Stream_Pointer( void );
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
// private class functions...
|
||||
//
|
||||
void Reset( void );
|
||||
//
|
||||
// private class data...
|
||||
//
|
||||
#if( SUPPORT_HANDLES )
|
||||
HANDLE File_Handle;
|
||||
#endif
|
||||
|
||||
#if( SUPPORT_STREAMS )
|
||||
//--------------------------------------------------------------------
|
||||
// The _stat structure, defined in SYS\STAT.H, includes these fields.
|
||||
// st_atime Time of last access of file ( time_t ).
|
||||
// st_ctime Time of creation of file ( time_t ).
|
||||
// st_dev Drive number of the disk containing the file (same as st_rdev).
|
||||
// st_rdev Drive number of the disk containing the file (same as st_dev).
|
||||
// st_mode Bit mask for file-mode information.
|
||||
// _S_IFDIR bit is set if path specifies a directory;
|
||||
// _S_IFREG bit is set if path specifies an ordinary file or a device.
|
||||
// User read/write bits are set according to the file's permission
|
||||
// mode; user execute bits are set according to the filename extension.
|
||||
// st_mtime Time of last modification of file.
|
||||
// st_nlink Always 1 on non-NTFS file systems.
|
||||
// st_size Size of the file in bytes; a 64-bit integer for _stati64 and _wstati64
|
||||
//--------------------------------------------------------------------
|
||||
FILE *File_Stream_Ptr;
|
||||
struct stat File_Statistics;
|
||||
#endif
|
||||
|
||||
char File_Name[ MAX_PATH_SIZE ];
|
||||
bool Currently_Open;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// non-class public functions...
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#if( SUPPORT_HANDLES )
|
||||
HANDLE Open_File( char const *file_name, int mode );
|
||||
bool Close_File( HANDLE handle );
|
||||
int Read_File( HANDLE handle,
|
||||
void *buffer,
|
||||
unsigned long int bytes_to_read );
|
||||
int Write_File( HANDLE handle,
|
||||
void const *buffer,
|
||||
unsigned long int bytes_to_write );
|
||||
bool Seek_File( HANDLE handle,
|
||||
int distance,
|
||||
int seek_file_location );
|
||||
int Tell_File( HANDLE handle );
|
||||
int File_Size( HANDLE handle );
|
||||
//
|
||||
// include path in name
|
||||
//
|
||||
bool Full_Path_File_Exists( char const *file_name );
|
||||
//
|
||||
// don't include path in name
|
||||
//
|
||||
bool HD_File_Exists( char const *file_name );
|
||||
bool CD_File_Exists( char const *file_name );
|
||||
// bool Find_File( char const *file_name );
|
||||
#endif
|
||||
|
||||
#if( SUPPORT_STREAMS )
|
||||
//
|
||||
// include path in name
|
||||
//
|
||||
bool Full_Path_File_Exists( char const *file_name );
|
||||
//
|
||||
// don't include path in name
|
||||
//
|
||||
bool HD_File_Exists( char const *file_name );
|
||||
bool CD_File_Exists( char const *file_name );
|
||||
// bool Find_File( char const *file_name );
|
||||
#endif
|
||||
|
||||
#endif // WND_FILE_H
|
1625
Generals/Code/Tools/Autorun/Wnd_file.cpp
Normal file
1625
Generals/Code/Tools/Autorun/Wnd_file.cpp
Normal file
File diff suppressed because it is too large
Load diff
5437
Generals/Code/Tools/Autorun/autorun.cpp
Normal file
5437
Generals/Code/Tools/Autorun/autorun.cpp
Normal file
File diff suppressed because it is too large
Load diff
246
Generals/Code/Tools/Autorun/autorun.h
Normal file
246
Generals/Code/Tools/Autorun/autorun.h
Normal file
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/************************************************************************************************
|
||||
* C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S *
|
||||
*************************************************************************************************
|
||||
*
|
||||
* FILE
|
||||
* $Archive: /Renegade Setup/Autorun/autorun.h $
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* PROGRAMMER
|
||||
* $Author: Maria_l $
|
||||
*
|
||||
* VERSION INFO
|
||||
* $Modtime: 1/28/02 11:11a $
|
||||
* $Revision: 10 $
|
||||
*
|
||||
*************************************************************************************************/
|
||||
|
||||
|
||||
#ifndef AUTORUN_H
|
||||
#define AUTORUN_H
|
||||
|
||||
#include <tchar.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "ttfont.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Externs
|
||||
//--------------------------------------------------------------------
|
||||
extern int Language;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Structs that everyone can use.
|
||||
//--------------------------------------------------------------------
|
||||
typedef enum {
|
||||
LANG_USA, //0
|
||||
LANG_UK, //1
|
||||
LANG_GER, //2
|
||||
LANG_FRE, //3
|
||||
LANG_DUT, //4
|
||||
LANG_ITA, //5
|
||||
LANG_JAP, //6
|
||||
LANG_SPA, //7
|
||||
LANG_SCA, //8
|
||||
LANG_KOR, //9
|
||||
LANG_CHI, //10
|
||||
LANG_NUM,
|
||||
} LanguageType;
|
||||
|
||||
#define IS_LANGUAGE_DBCS(l) (((l)==LANG_CHI)||((l)==LANG_JAP)||((l)==LANG_KOR)) // [OYO]
|
||||
#define IS_CODEPAGE_DBCS(C) ((C==949)||(C==950)||(C==932)) // [OYO]
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DEFINES
|
||||
//----------------------------------------------------------------------------
|
||||
#define MAX_COMMAND_LINE_ARGUMENTS 10
|
||||
#define MAX_ARGUMENT_LENGTH 80
|
||||
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
#define WM_GO (WM_USER)+1
|
||||
#define WM_USERSTAT (WM_USER + 100)
|
||||
|
||||
#define EXPLORER_NAME "EXPLORER.EXE"
|
||||
#define INSTALL_PATH_KEY "InstallPath"
|
||||
#define INTERNET_PATH_KEY "InternetPath"
|
||||
#define SETUP_NAME "Setup.exe"
|
||||
#define UNINSTALL_NAME "Uninst.exe"
|
||||
|
||||
#define SHELL_FOLDERS_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
|
||||
#define SHELL_UNINSTALL_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
|
||||
#define SHELL_APP_PATHS_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"
|
||||
#define PROGRAMS_SUBKEY "Programs"
|
||||
#define COMMON_PROGRAMS_SUBKEY "Common Programs"
|
||||
#define SOFTWARE_SUBKEY "Software"
|
||||
/*
|
||||
#define WESTWOOD_SUBKEY "Westwood"
|
||||
#define SOFTWARE_WESTWOOD_KEY "Software\\Westwood\\"
|
||||
#define WESTWOOD_WOLAPI_KEY "Software\\Westwood\\WOLAPI"
|
||||
#define WESTWOOD_REGISTER_KEY "Software\\Westwood\\Register"
|
||||
*/
|
||||
#define ELECTRONICARTS_SUBKEY "Electronic Arts"
|
||||
#define EAGAMES_SUBKEY "EA Games"
|
||||
#define GENERALS_SUBKEY "Generals"
|
||||
#define SOFTWARE_EAGAMES_KEY "Software\\Electronic Arts\\EA Games\\"
|
||||
#define EAGAMES_GENERALS_KEY "Software\\Electronic Arts\\EA Games\\Generals"
|
||||
#define EAGAMES_ERGC_KEY "Software\\Electronic Arts\\EA Games\\Generals\\ergc"
|
||||
#define LAUNCHER_FILENAME "Generals.exe"
|
||||
#define WORLDBUILDER_FILENAME "WorldBuilder.exe"
|
||||
#define PATCHGET_FILENAME "patchget.dat"
|
||||
|
||||
#define UNINSTALL_STRING_SUBKEY "UninstallString"
|
||||
#define INSTALLPATH_SUBKEY "InstallPath"
|
||||
#define VERSION_SUBKEY "Version"
|
||||
#define LANGUAGE_SUBKEY "Language"
|
||||
#define MAPPACKVERSION_SUBKEY "MapPackVersion"
|
||||
|
||||
#define DDRAW "DDRAW.DLL"
|
||||
#define DSOUND "DSOUND.DLL"
|
||||
#define DDHELP "DDHELP.EXE"
|
||||
|
||||
#define NORMAL "Normal"
|
||||
#define FOCUSED "Focused"
|
||||
#define PRESSED "Pressed"
|
||||
/*
|
||||
#define BUTTON1NORMAL "Button1Normal"
|
||||
#define BUTTON2NORMAL "Button2Normal"
|
||||
#define BUTTON3NORMAL "Button3Normal"
|
||||
#define BUTTON4NORMAL "Button4Normal"
|
||||
#define BUTTON5NORMAL "Button5Normal"
|
||||
#define BUTTON6NORMAL "Button6Normal"
|
||||
#define BUTTON7NORMAL "Button7Normal"
|
||||
#define BUTTON8NORMAL "Button8Normal"
|
||||
#define BUTTON9NORMAL "Button8Normal"
|
||||
#define BUTTON10NORMAL "Button8Normal"
|
||||
|
||||
#define BUTTON1FOCUSED "Button1Focused"
|
||||
#define BUTTON2FOCUSED "Button2Focused"
|
||||
#define BUTTON3FOCUSED "Button3Focused"
|
||||
#define BUTTON4FOCUSED "Button4Focused"
|
||||
#define BUTTON5FOCUSED "Button5Focused"
|
||||
#define BUTTON6FOCUSED "Button6Focused"
|
||||
#define BUTTON7FOCUSED "Button7Focused"
|
||||
#define BUTTON8FOCUSED "Button8Focused"
|
||||
#define BUTTON9FOCUSED "Button8Focused"
|
||||
#define BUTTON10FOCUSED "Button8Focused"
|
||||
*/
|
||||
|
||||
#define BUTTON_REG "BUTTON_REG"
|
||||
#define BUTTON_SEL "BUTTON_SEL"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// LaunchObject Class
|
||||
//-------------------------------------------------------------------------
|
||||
class LaunchObjectClass
|
||||
{
|
||||
public:
|
||||
LaunchObjectClass ( char *path=NULL, char *args=NULL );
|
||||
|
||||
void SetPath ( char *path );
|
||||
void SetArgs ( char *args );
|
||||
unsigned int Launch ( void );
|
||||
bool Launch_A_Program ( void ) { return( LaunchSomething ); };
|
||||
void Set_Launch ( bool value ) { LaunchSomething = value; };
|
||||
|
||||
public:
|
||||
char szPath[ _MAX_PATH ];
|
||||
char szArgs[ _MAX_PATH ];
|
||||
bool LaunchSomething;
|
||||
};
|
||||
|
||||
extern LaunchObjectClass LaunchObject;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Main Class
|
||||
//-------------------------------------------------------------------------
|
||||
class Main
|
||||
{
|
||||
public:
|
||||
static HINSTANCE hInstance;
|
||||
static HINSTANCE hPrevInstance;
|
||||
static HMODULE hModule;
|
||||
static int nCmdShow;
|
||||
static int MessageLoop( void );
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// (Base)Window Class
|
||||
//
|
||||
// Note that Window_Proc is a "pure virtual" function making this an
|
||||
// abstract class.
|
||||
//-------------------------------------------------------------------------
|
||||
class Window
|
||||
{
|
||||
protected:
|
||||
HWND hWnd;
|
||||
|
||||
public:
|
||||
HWND GetHandle( void ) { return hWnd; }
|
||||
BOOL Show( int nCmdShow ) { return ShowWindow( hWnd, nCmdShow ); }
|
||||
void Update( void ) { UpdateWindow( hWnd ); }
|
||||
virtual LRESULT Window_Proc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam ) = 0;
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// MainWindow Class
|
||||
//-------------------------------------------------------------------------
|
||||
class MainWindow : public Window
|
||||
{
|
||||
protected:
|
||||
|
||||
static char szClassName[ 100 ];
|
||||
|
||||
public:
|
||||
|
||||
MainWindow( void );
|
||||
|
||||
static void Register ( void );
|
||||
static void Reset_Class_Name ( char *string )
|
||||
{
|
||||
if ( string != NULL && string[0] != '\0' ) {
|
||||
strcpy( szClassName, string );
|
||||
}
|
||||
};
|
||||
|
||||
BOOL Is_Product_Registered ( void );
|
||||
void Create_Buttons ( HWND hWnd, RECT *dlg_rect );
|
||||
unsigned int Run_Auto_Update ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_Demo ( HWND hWnd, RECT *rect, int cd_drive );
|
||||
BOOL Run_Explorer ( char *, HWND hWnd, RECT *rect );
|
||||
unsigned int Run_Game ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_WorldBuilder ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_PatchGet ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_New_Account ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_Register ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_Setup ( HWND hWnd, RECT *rect, int cd_drive );
|
||||
unsigned int Run_Uninstall ( HWND hWnd, RECT *rect );
|
||||
unsigned int Run_OpenFile (int cd_drive, const char *filename, bool wait = false);
|
||||
LRESULT Window_Proc ( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
307
Generals/Code/Tools/Autorun/gimex.h
Normal file
307
Generals/Code/Tools/Autorun/gimex.h
Normal file
|
@ -0,0 +1,307 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Copyright (C) Electronic Arts Canada Inc. 1994-1998. All rights reserved. */
|
||||
|
||||
/* ABSTRACT
|
||||
gimex.h - Graphics IMport EXport (GIMEX) v2.26
|
||||
@ */
|
||||
|
||||
#ifndef __GIMEX_H
|
||||
#define __GIMEX_H 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define GimexVersion "2.26"
|
||||
|
||||
/****************************************************************************/
|
||||
/* Data Types */
|
||||
/****************************************************************************/
|
||||
|
||||
/* ARGB structure used for palettes/pixels */
|
||||
|
||||
#ifndef _ARGB_T
|
||||
#define _ARGB_T
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(PSX) || defined(DC)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char b,g,r,a;
|
||||
} ARGB;
|
||||
|
||||
#elif defined(SGI)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char a,b,g,r;
|
||||
} ARGB;
|
||||
|
||||
#else /* Mac */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char a,r,g,b;
|
||||
} ARGB;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Info structure describing bitmaps */
|
||||
|
||||
#define GIMEX_FRAMENAME_SIZE 32
|
||||
#define GIMEX_COMMENT_SIZE 256
|
||||
#define GIMEX_COLOURTBL_SIZE 256
|
||||
#define GIMEX_HOTSPOTTBL_SIZE 256
|
||||
#define GIMEX_HOTSPOTTBL_VALUES 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long signature; /* signature of gimex ie 'tga ' (optional) */
|
||||
long size; /* size of GINFO structure */
|
||||
int version; /* version number of GINFO structure (200) */
|
||||
int framenum; /* current frame */
|
||||
int width; /* width of bitmap in pixels */
|
||||
int height; /* height of bitmap in pixels */
|
||||
int bpp; /* bits per pixel (8 or 32) */
|
||||
int originalbpp; /* bits per pixel in original image (1 to 32) */
|
||||
int startcolour; /* first colour in palette */
|
||||
int numcolours; /* number of colours in original indexed palette */
|
||||
ARGB colourtbl[GIMEX_COLOURTBL_SIZE]; /* 8 bit palette */
|
||||
int subtype; /* internal format sub-type 0-default */
|
||||
int packed; /* type of packing on original image. 0 none, 1 run, n other */
|
||||
int quality; /* quality of lossy packing 0..100 */
|
||||
int framesize; /* size of frame in bytes */
|
||||
int alphabits; /* number of bits in alpha channel */
|
||||
int redbits; /* number of bits in red channel */
|
||||
int greenbits; /* number of bits in green channel */
|
||||
int bluebits; /* number of bits in blue channel */
|
||||
int centerx; /* center point relative to upper left corner */
|
||||
int centery;
|
||||
int defaultx; /* default coordinate point */
|
||||
int defaulty;
|
||||
int numhotspots; /* number of hot spots defined */
|
||||
char framename[GIMEX_FRAMENAME_SIZE]; /* null terminated name of frame/image */
|
||||
char comment[GIMEX_COMMENT_SIZE]; /* null terminated multiline user comment */
|
||||
int hotspottbl[GIMEX_HOTSPOTTBL_SIZE][GIMEX_HOTSPOTTBL_VALUES];/* up to 256 hot spots, XY pairs relative to upperleft */
|
||||
float dpi; /* dots per inch ie 72.0 */
|
||||
int reserved[3]; /* reserved for future use - set to zero */
|
||||
} GINFO;
|
||||
|
||||
#ifndef _GSTREAM_T
|
||||
#define _GSTREAM_T GIMEX
|
||||
typedef void GSTREAM; /* handle used for file functions */
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long signature; /* signature of gimex ie 'tga ' (optional) */
|
||||
long size; /* size of GINSTANCE structure */
|
||||
int frames; /* Number of frames in file */
|
||||
int framenum; /* current frame (optional) */
|
||||
GSTREAM *gstream; /* stream pointer for file */
|
||||
char *gref; /* gimex reference to additional memory used by module (optional) */
|
||||
} GINSTANCE;
|
||||
|
||||
/* Info structure describing bitmaps */
|
||||
|
||||
#define MAXMACTYPES 8
|
||||
#define MAXEXTENSIONS 8
|
||||
|
||||
#define GIMEX_EXTENSION_SIZE 8
|
||||
#define GIMEX_AUTHORSTR_SIZE 32
|
||||
#define GIMEX_VERSIONSTR_SIZE 8
|
||||
#define GIMEX_SHORTTYPESTR_SIZE 8
|
||||
#define GIMEX_WORDTYPESTR_SIZE 16
|
||||
#define GIMEX_LONGTYPESTR_SIZE 32
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long signature; /* signature of gimex ie 'tga ' (optional) */
|
||||
long size; /* size of GABOUT structure */
|
||||
int version; /* version number of GABOUT structure (200) */
|
||||
unsigned int canimport :1; /* supports importing */
|
||||
unsigned int canexport :1; /* supports exporting */
|
||||
unsigned int importpacked :2; /* max import packed field 0..3 */
|
||||
unsigned int exportpacked :2; /* max export packed field 0..3 */
|
||||
unsigned int import8 :1; /* supports importing 8 bit indexed */
|
||||
unsigned int export8 :1; /* supports exporting 8 bit indexed */
|
||||
unsigned int import32 :1; /* supports importing 32 bit direct rgb */
|
||||
unsigned int export32 :1; /* supports exporting 32 bit direct rgb */
|
||||
unsigned int multiframe :1; /* supports multiple frames */
|
||||
unsigned int multifile :1; /* format requires additional files or resource fork */
|
||||
unsigned int multisize :1; /* supports different size per frame */
|
||||
unsigned int framebuffer :1; /* module requires memory to buffer entire frame */
|
||||
unsigned int external :1; /* module requires external tool or plugin */
|
||||
unsigned int usesfile :1; /* module is file based vs ads/printer/generator */
|
||||
unsigned int singlepalette :1; /* limited to a single palette per file */
|
||||
unsigned int greyscale :1; /* use maxcolours for number of levels */
|
||||
unsigned int startcolour :1; /* supports start colour */
|
||||
unsigned int dotsubtype :1; /* subtype based on extension */
|
||||
unsigned int resizable :1; /* read will respect ginfo width & height */
|
||||
unsigned int pad :11; /* pad bitfield to 32 bit boundary for inter compiler compatibility */
|
||||
int maxcolours; /* only use in 8 bit, 0 if module does not care */
|
||||
int maxframename; /* maximum characters in ginfo framename */
|
||||
int defaultquality; /* default pack quality */
|
||||
long mactype[MAXMACTYPES]; /* mac file system types used */
|
||||
char extensions[MAXEXTENSIONS][GIMEX_EXTENSION_SIZE]; /* null terminated extensions with '.' */
|
||||
char authorstr[GIMEX_AUTHORSTR_SIZE]; /* name of gimex module author */
|
||||
char versionstr[GIMEX_VERSIONSTR_SIZE]; /* version number of gimex module ie 1.00 */
|
||||
char shorttypestr[GIMEX_SHORTTYPESTR_SIZE]; /* 3 or 4 character type string ie TGA */
|
||||
char wordtypestr[GIMEX_WORDTYPESTR_SIZE]; /* single word type string ie Targa */
|
||||
char longtypestr[GIMEX_LONGTYPESTR_SIZE]; /* full name of data format ie True Vision Targa */
|
||||
} GABOUT;
|
||||
|
||||
/* Bitmap structure (optional) */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GINFO *ginfo;
|
||||
char *image;
|
||||
int rowbytes;
|
||||
} GBITMAP;
|
||||
|
||||
#define GMAKEID(a,b,c,d) (((long)(a)<<24)|((long)(b)<<16)|((long)(c)<<8)|(long)(d))
|
||||
|
||||
#ifndef gmin
|
||||
#define gmin(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef gmax
|
||||
#define gmax(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#if !defined(GCALL)
|
||||
#if defined(_MSC_VER) || defined(__WATCOMC__)
|
||||
#define GCALL __stdcall
|
||||
#else
|
||||
#define GCALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* disable unreferenced parameters warnings */
|
||||
#if defined(__WATCOMC__)
|
||||
#pragma warning 202 999999
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable : 4100)
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/****************************************************************************/
|
||||
/* Gimex Module Example Prototypes */
|
||||
/****************************************************************************/
|
||||
|
||||
/* Example Information Functions */
|
||||
|
||||
GABOUT * GCALL aboutbmp(void);
|
||||
int GCALL isbmp(GSTREAM *g);
|
||||
|
||||
/* Example Import Functions */
|
||||
|
||||
int GCALL openbmp(GINSTANCE **gx, GSTREAM *g, char *pathname);
|
||||
GINFO * GCALL infobmp(GINSTANCE *gx, int framenum);
|
||||
int GCALL readbmp(GINSTANCE *gx, GINFO *ginfo, char *dest, int rowbytes);
|
||||
int GCALL closebmp(GINSTANCE *gx);
|
||||
|
||||
/* Example Export Functions */
|
||||
|
||||
int GCALL wopenbmp(GINSTANCE **gx, GSTREAM *g, char *pathname, int numframes);
|
||||
int GCALL writebmp(GINSTANCE *gx, GINFO *ginfo, char *source, int rowbytes);
|
||||
int GCALL wclosebmp(GINSTANCE *gx);
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************/
|
||||
/* Application Module Prototypes */
|
||||
/****************************************************************************/
|
||||
|
||||
/* File Stream Functions */
|
||||
|
||||
GSTREAM * GCALL gopen(const char *pathname);
|
||||
GSTREAM * GCALL gwopen(const char *pathname);
|
||||
int GCALL gclose(GSTREAM *g);
|
||||
int GCALL gread(GSTREAM *g, void *buf, long size);
|
||||
int GCALL gwrite(GSTREAM *g, void *buf, long size);
|
||||
int GCALL gseek(GSTREAM *g, long offset);
|
||||
long GCALL glen(GSTREAM *g);
|
||||
long GCALL gtell(GSTREAM *g);
|
||||
|
||||
/* Memory Functions */
|
||||
|
||||
void * GCALL galloc(long size);
|
||||
int GCALL gfree(void *memptr);
|
||||
void gputm(void *memptr, unsigned long val, int numbytes);
|
||||
void gputi(void *memptr, unsigned long val, int numbytes);
|
||||
unsigned long ggetm(void *memptr, int numbytes);
|
||||
unsigned long ggeti(void *memptr, int numbytes);
|
||||
|
||||
/****************************************************************************/
|
||||
/* Watcom Memory Functions */
|
||||
/****************************************************************************/
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(__NOINLINE__)
|
||||
#pragma aux ggeti = \
|
||||
"mov eax,[eax+ecx-4]" \
|
||||
"neg ecx" \
|
||||
"lea ecx,32[ecx*8]" \
|
||||
"shr eax,cl" \
|
||||
parm [eax] [ecx] \
|
||||
modify [eax ecx] \
|
||||
value [eax];
|
||||
|
||||
#pragma aux ggetm = \
|
||||
".586" \
|
||||
"mov eax,[eax]" \
|
||||
"bswap eax" \
|
||||
"neg ecx" \
|
||||
"lea ecx,32[ecx*8]" \
|
||||
"shr eax,cl" \
|
||||
parm [eax] [ecx] \
|
||||
modify [eax ecx] \
|
||||
value [eax];
|
||||
|
||||
unsigned long bswap(unsigned long val);
|
||||
#pragma aux bswap = "bswap eax" parm [eax] modify [eax] value [eax];
|
||||
|
||||
#define gputm(putmdest,putmdata,putmbytes) \
|
||||
(((int)(putmbytes)==4) ? ((void)(*((unsigned long *) (putmdest)) = bswap((unsigned long)(putmdata)))) \
|
||||
: (((int)(putmbytes)==1) ? ((void)(*((unsigned char *) (putmdest)) = (unsigned char)(putmdata))) \
|
||||
: (((int)(putmbytes)==2) ? ((void)(*((unsigned short *) (putmdest)) = (unsigned short)(bswap((unsigned long)(putmdata))>>16))) \
|
||||
: (((int)(putmbytes)==3) ? ((void)(*((unsigned char *) (putmdest)+2) = (unsigned char)(putmdata)),(void)(*((unsigned short *) (putmdest)) = (unsigned short)(bswap((unsigned long)(putmdata))>>8))) \
|
||||
: (void)0))))
|
||||
|
||||
#define gputi(putidest,putidata,putibytes) \
|
||||
(((int)(putibytes)==4) ? ((void)(*((unsigned long *) (putidest)) = ((unsigned long)(putidata)))) \
|
||||
: (((int)(putibytes)==1) ? ((void)(*((unsigned char *) (putidest)) = (unsigned char)(putidata))) \
|
||||
: (((int)(putibytes)==2) ? ((void)(*((unsigned short *) (putidest)) = (unsigned short)(putidata))) \
|
||||
: (((int)(putibytes)==3) ? ((void)(*((unsigned short *) (putidest)) = (unsigned short)(putidata)),(void)(*((unsigned char *) (putidest)+2) = (unsigned char)((unsigned long)(putidata)>>16))) \
|
||||
: (void)0))))
|
||||
|
||||
#endif /* __WATCOMC__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __GIMEX_H */
|
||||
/* END ABSTRACT */
|
||||
|
||||
|
||||
|
31
Generals/Code/Tools/Autorun/leanAndMeanAutorun.h
Normal file
31
Generals/Code/Tools/Autorun/leanAndMeanAutorun.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// FILE: leanAndMeanAutorun.h /////////////////////////////////////////////////////////////////////
|
||||
// Author: Mark Lorenzen, January 2003!
|
||||
// Description: Classes extracted from GameEngine for use in autorun without having to link the game to autorun
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#ifndef __LEANANDMEANAUTORUN_H_
|
||||
#define __LEANANDMEANAUTORUN_H_
|
||||
|
||||
|
||||
#define LEAN_AND_MEAN
|
||||
|
||||
#endif //__LEANANDMEANAUTORUN_H_
|
864
Generals/Code/Tools/Autorun/locale.cpp
Normal file
864
Generals/Code/Tools/Autorun/locale.cpp
Normal file
|
@ -0,0 +1,864 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Copyright (C) Electronic Arts Canada Inc. 1998-1999. All rights reserved. */
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "gimex.h" /* for file and memory IO only */
|
||||
#include "locale.h"
|
||||
#include "wnd_file.h"
|
||||
|
||||
/*************************************************************************/
|
||||
/* File Format Structures */
|
||||
/*************************************************************************/
|
||||
|
||||
#define LOCALEFILE_HEADERCHUNKID 0x48434f4c /* 'LOCH' */
|
||||
#define LOCALEFILE_INDEXCHUNKID 0x49434f4c /* 'LOCI' */
|
||||
#define LOCALEFILE_LANGUAGECHUNKID 0x4c434f4c /* 'LOCL' */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int ChunkID; /* 'LOCH' LOCALEFILE_HEADERCHUNKID */
|
||||
unsigned int ChunkSize; /* size of chunk in bytes */
|
||||
unsigned int Flags; /* 0=no index chunk present,1=index chunk present */
|
||||
unsigned int LanguageCount; /* number of language chunks in this file */
|
||||
/* unsigned int LanguageOffset[LanguageCount]; \\ offsets in bytes from start of file to language chunk */
|
||||
} LOCALEFILE_HEADERCHUNK;
|
||||
|
||||
/* offset LOCALEFILE_HEADERCHUNK_LANGUAGE_OFFSET bytes from the start of the chunk to the language offset table */
|
||||
#define LOCALEFILE_HEADERCHUNK_LANGUAGE_OFFSET sizeof(LOCALEFILE_HEADERCHUNK)
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int ChunkID; /* 'LOCI' LOCALEFILE_INDEXCHUNKID */
|
||||
unsigned int ChunkSize; /* size of chunk in bytes */
|
||||
unsigned int StringCount; /* number of string ids in this chunk (same value in all language chunks) */
|
||||
unsigned int pad; /* must be zero */
|
||||
/* STRINGID StringID[StringCount]; */
|
||||
/* { */
|
||||
/* unsigned short ID; \\ id that user gives to look up value */
|
||||
/* unsigned short Index; \\ index to look up value in language chunks */
|
||||
/* } */
|
||||
} LOCALEFILE_INDEXCHUNK;
|
||||
|
||||
/* offset LOCALEFILE_INDEXCHUNK_STRINGID_OFFSET bytes from the start of the chunk to the string id table */
|
||||
#define LOCALEFILE_INDEXCHUNK_STRINGID_OFFSET sizeof(LOCALEFILE_INDEXCHUNK)
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int ChunkID; /* 'LOCL' LOCALEFILE_LANGUAGECHUNKID */
|
||||
unsigned int ChunkSize; /* size of chunk in bytes including this header and all string data */
|
||||
unsigned int LanguageID; /* language strings are in for this bank */
|
||||
unsigned int StringCount; /* number of strings in this chunk */
|
||||
/* unsigned int StringOffset[StringCount]; \\ offsets in bytes from start of chunk to string */
|
||||
/* const char* Data[StringCount]; \\ StringCount null terminated strings */
|
||||
} LOCALEFILE_LANGUAGECHUNK;
|
||||
|
||||
/* offset LOCALEFILE_LANGUAGECHUNK_STRING_OFFSETbytes from the start of the chunk to the string offset table */
|
||||
#define LOCALEFILE_LANGUAGECHUNK_STRING_OFFSET sizeof(LOCALEFILE_LANGUAGECHUNK)
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* LOCALE_INSTANCE declaration */
|
||||
/*************************************************************************/
|
||||
|
||||
typedef LOCALEFILE_HEADERCHUNK HEADER;
|
||||
typedef LOCALEFILE_INDEXCHUNK INDEX;
|
||||
typedef LOCALEFILE_LANGUAGECHUNK BANK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int BankIndex; /* current language bank set (0..BANK_COUNT-1) */
|
||||
BANK* pBank[LOCALE_BANK_COUNT]; /* array of string banks */
|
||||
INDEX* pIndex[LOCALE_BANK_COUNT]; /* array of string indices */
|
||||
} LOCALE_INSTANCE;
|
||||
|
||||
static LOCALE_INSTANCE *lx = NULL;
|
||||
|
||||
/*************************************************************************/
|
||||
/* initialization/restore */
|
||||
/*************************************************************************/
|
||||
|
||||
/* helper function to make assertions for initialization clearer */
|
||||
int LOCALE_isinitialized( void )
|
||||
{
|
||||
if ( lx == NULL ) {
|
||||
// TRACE("LOCALE API is not initialized - call LOCALE_init before calling LOCALE functions\n");
|
||||
}
|
||||
return( lx != NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_init - Init the localization module
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; int LOCALE_init(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Initilizes everything needed to use the locale API. Can only be called
|
||||
; once until LOCALE_restore is called.
|
||||
;
|
||||
; Returns non-zero if everything went ok.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_restore
|
||||
;
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
int LOCALE_init(void)
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
/* ensure locale module is NOT already initialized */
|
||||
ASSERT(lx == NULL); /* can only call LOCALE_init after a restore or once, cannot double init locale API */
|
||||
|
||||
/* allocate instance */
|
||||
lx = (LOCALE_INSTANCE*)galloc(sizeof(LOCALE_INSTANCE));
|
||||
if (lx != NULL) {
|
||||
memset(lx, 0, sizeof(LOCALE_INSTANCE));
|
||||
ok = 1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_restore - Free resources used by the locale module
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; void LOCALE_restore(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Restores all resources used by the locale API. Can only be called after
|
||||
; LOCALE_init, and only once.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_init
|
||||
;
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
void LOCALE_restore(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if( lx != NULL ) {
|
||||
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
ASSERT(lx != NULL);
|
||||
|
||||
/* free any language tables */
|
||||
for (i = 0; i < LOCALE_BANK_COUNT; i++) {
|
||||
if (lx->pBank[i]) {
|
||||
LOCALE_setbank(i);
|
||||
LOCALE_freetable();
|
||||
}
|
||||
}
|
||||
|
||||
/* free instance */
|
||||
gfree(lx);
|
||||
lx = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/* attributes */
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_setbank - Set the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; void LOCALE_setbank(BankIndex)
|
||||
; int BankIndex; Number between 0 and LOCALE_BANK_COUNT - 1
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Sets the current bank to be active. All functions will now use this
|
||||
; bank for strings. A bank is slot where a string table is loaded.
|
||||
; More than one bank can have a table loaded but the locale functions
|
||||
; only work on one bank at a time, the active bank set by this function.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_getbank
|
||||
;
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
void LOCALE_setbank(int BankIndex)
|
||||
{
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
lx->BankIndex = BankIndex;
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_getbank - Get the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; int LOCALE_getbank(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Returns the bank index of the current bank.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_setbank
|
||||
;
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
int LOCALE_getbank(void)
|
||||
{
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
return lx->BankIndex;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_getbanklanguageid - Get the language id for the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; int LOCALE_getbanklanguageid(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Returns the language id of the current bank. This id will match
|
||||
; the lanugage id in the header file generated by Locomoto
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_loadtable
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
int LOCALE_getbanklanguageid(void)
|
||||
{
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
ASSERT(lx->pBank[lx->BankIndex]); /* must load a table into bank before calling this function */
|
||||
return (int)(lx->pBank[lx->BankIndex]->LanguageID);
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_getbankstringcount - Get the string count for the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; int LOCALE_getbankstringcount(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Returns the number of strings in the current bank. If zero is
|
||||
; returned then this bank is empty.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_loadtable
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
int LOCALE_getbankstringcount(void)
|
||||
{
|
||||
int StringCount = 0;
|
||||
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
if (lx->pBank[lx->BankIndex]) {
|
||||
StringCount = lx->pBank[lx->BankIndex]->StringCount;
|
||||
}
|
||||
return StringCount;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/* operations */
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_loadtable - Load a string table into the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; int LOCALE_loadtable(pathname, languageid)
|
||||
;
|
||||
; const char* pathname; // pathname of .loc file to load
|
||||
; int languageid; // language id to load (from .h file)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Loads the specified language from the string file into the
|
||||
; current bank. Returns non zero if the operation was succesful.
|
||||
; The bank must be free before you can call LOCALE_loadtable. To
|
||||
; free a bank use the LOCALE_freetable function. To determine
|
||||
; if the bank is free use the LOCALE_getbankstringcount function.
|
||||
;
|
||||
; The languageid value is available in the .h file created by
|
||||
; locomoto.
|
||||
;
|
||||
; Returns non-zero if everthing is ok.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_freetable, LOCALE_getbankstringcount
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
static int readheader( GSTREAM* g )
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
/* read file header */
|
||||
LOCALEFILE_HEADERCHUNK header;
|
||||
int HeaderChunkSize = sizeof(LOCALEFILE_HEADERCHUNK);
|
||||
|
||||
// VERIFY(gread(g, &header, HeaderChunkSize) == HeaderChunkSize);
|
||||
if( gread(g, &header, HeaderChunkSize) != HeaderChunkSize ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, "readheader - HeaderChunkSize = %d.", HeaderChunkSize );
|
||||
Msg( __LINE__, __FILE__, "readheader - header.LanguageCount = %d.", header.LanguageCount );
|
||||
Msg( __LINE__, __FILE__, "readheader - header.Flags = %d.", header.Flags );
|
||||
|
||||
ASSERT( header.ChunkID == LOCALEFILE_HEADERCHUNKID ); /* ensure that this is a valid .loc file */
|
||||
|
||||
/* read index chunk if present */
|
||||
if ( header.Flags == 1 ) {
|
||||
|
||||
int IndexChunkSize;
|
||||
int IndexChunkPos = header.ChunkSize;
|
||||
|
||||
/* read index chunk size */
|
||||
// VERIFY(gseek(g, IndexChunkPos + 4));
|
||||
if( !gseek( g, IndexChunkPos + 4)) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, "readheader - seek to = %d.", IndexChunkPos + 4 );
|
||||
|
||||
// VERIFY(gread(g, &IndexChunkSize, 4) == 4);
|
||||
if( gread( g, &IndexChunkSize, 4) != 4 ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, "readheader - IndexChunkSize = %d.", IndexChunkSize );
|
||||
|
||||
/* alloc and read index chunk */
|
||||
lx->pIndex[lx->BankIndex] = (LOCALEFILE_INDEXCHUNK *)galloc((long)IndexChunkSize );
|
||||
if (lx->pIndex[lx->BankIndex]) {
|
||||
|
||||
// VERIFY(gseek(g, IndexChunkPos));
|
||||
gseek( g, IndexChunkPos );
|
||||
|
||||
Msg( __LINE__, __FILE__, "readheader - seek to = %d.", IndexChunkPos );
|
||||
|
||||
// VERIFY(gread(g, lx->pIndex[lx->BankIndex], IndexChunkSize) == IndexChunkSize);
|
||||
if ( gread(g, lx->pIndex[lx->BankIndex], IndexChunkSize ) != IndexChunkSize ) {
|
||||
return ok;
|
||||
}
|
||||
Msg( __LINE__, __FILE__, "readheader - IndexChunkSize = %d.", IndexChunkSize );
|
||||
|
||||
ASSERT( lx->pIndex[lx->BankIndex]->ChunkID == LOCALEFILE_INDEXCHUNKID );
|
||||
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
Msg( __LINE__, __FILE__, "readheader - exiting." );
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int readstrings( GSTREAM* g, int LanguageID )
|
||||
{
|
||||
Msg( __LINE__, __FILE__, "readstrings:: g ok? %d.", ((g!= NULL)?1:0));
|
||||
|
||||
int ok = 0;
|
||||
|
||||
int LanguageChunkOffsetPos = 16 + LanguageID*4;
|
||||
int LanguageChunkPos = 0;
|
||||
int LanguageChunkSize = -1;
|
||||
|
||||
/* read offset to language chunk */
|
||||
// VERIFY(gseek(g, (int)LanguageChunkOffsetPos));
|
||||
// VERIFY(gread(g, &LanguageChunkPos, 4) == 4);
|
||||
if( !gseek( g, (int)LanguageChunkOffsetPos )) {
|
||||
return ok;
|
||||
}
|
||||
if( gread( g, &LanguageChunkPos, 4 ) != 4 ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* read language chunk size */
|
||||
// VERIFY(gseek(g, LanguageChunkPos + 4));
|
||||
// VERIFY(gread(g, &LanguageChunkSize, 4) == 4);
|
||||
if( !gseek( g, LanguageChunkPos + 4 )) {
|
||||
return ok;
|
||||
}
|
||||
if( gread( g, &LanguageChunkSize, 4 ) != 4 ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, "readstrings::LanguageChunkOffsetPos = %d.", LanguageChunkOffsetPos );
|
||||
Msg( __LINE__, __FILE__, "readstrings::LanguageChunkPos = %d.", LanguageChunkPos );
|
||||
Msg( __LINE__, __FILE__, "readstrings::LanguageChunkSize = %d.", LanguageChunkSize );
|
||||
|
||||
/* alloc and read language chunk */
|
||||
lx->pBank[lx->BankIndex] = (LOCALEFILE_LANGUAGECHUNK *)galloc((long)LanguageChunkSize);
|
||||
if (lx->pBank[lx->BankIndex]) {
|
||||
|
||||
Msg( __LINE__, __FILE__, "readstrings:: A." );
|
||||
|
||||
// VERIFY(gseek(g, LanguageChunkPos));
|
||||
// VERIFY(gread(g, lx->pBank[lx->BankIndex], LanguageChunkSize) == LanguageChunkSize);
|
||||
if( !gseek( g, LanguageChunkPos )) {
|
||||
return ok;
|
||||
}
|
||||
if( gread( g, lx->pBank[lx->BankIndex], LanguageChunkSize ) != LanguageChunkSize ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
ASSERT(lx->pBank[lx->BankIndex]->ChunkID == LOCALEFILE_LANGUAGECHUNKID);
|
||||
ok = 1;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
int LOCALE_loadtable(const char* PathName, int LanguageID)
|
||||
{
|
||||
int ok = 0;
|
||||
GSTREAM* g;
|
||||
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
ASSERT(lx->pBank[lx->BankIndex] == NULL); /* bank must be empty before loading a new table */
|
||||
ASSERT(lx->pIndex[lx->BankIndex] == NULL); /* bank must be empty before loading a new table */
|
||||
|
||||
g = gopen( PathName );
|
||||
if( g != NULL ) {
|
||||
|
||||
Msg( __LINE__, __FILE__, "LOCALE_loadtable-- file opened." );
|
||||
|
||||
if( readheader(g)) {
|
||||
|
||||
Msg( __LINE__, __FILE__, "LOCALE_loadtable-- readstrings." );
|
||||
|
||||
ok = readstrings( g, LanguageID );
|
||||
|
||||
Msg( __LINE__, __FILE__, "LOCALE_loadtable-- ok = %d ).", ok );
|
||||
}
|
||||
gclose(g);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_purgetable - OBSOLETE
|
||||
;
|
||||
; Make all references to LOCALE_freetable
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_freetable - Free the string table in the current bank
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; void LOCALE_freetable(void)
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Frees the table loaded in the current bank. There must be a
|
||||
; table loaded in the current bank. Use LOCALE_getbankstringcount
|
||||
; to determine if the bank is free or not.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_loadtable, LOCALE_getbankstringcount
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
void LOCALE_freetable(void)
|
||||
{
|
||||
if( lx != NULL ) {
|
||||
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
ASSERT(lx->pBank[lx->BankIndex]); /* table must be loaded before calling this function */
|
||||
|
||||
/* free string bank */
|
||||
gfree(lx->pBank[lx->BankIndex]);
|
||||
lx->pBank[lx->BankIndex] = NULL;
|
||||
|
||||
/* if the bank has an index loaded, free that as well */
|
||||
if (lx->pIndex[lx->BankIndex]) {
|
||||
gfree(lx->pIndex[lx->BankIndex]);
|
||||
lx->pIndex[lx->BankIndex] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_getstring - Return the specified string from the current bank
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; const char* LOCALE_getstring( StringID )
|
||||
; int StringID; ID of string to return
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Returns the string specified from the current bank. There must
|
||||
; be a string table loaded into the current bank. Use the String
|
||||
; ID specified in the header file created by Locomoto. Note that
|
||||
; the string pointer is a const pointer. Do not modify the string
|
||||
; or the Locale library may return invalid results.
|
||||
;
|
||||
; If the .loc file was created with an index StringID can be any
|
||||
; valid integer in the range 0..65535. If no index was created
|
||||
; with the .loc file StringID will be a zero based array index.
|
||||
;
|
||||
; String is returned by const for a reason. Bad things will happen
|
||||
; if you modify it. You have been warned.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; LOCALE_loadtable, LOCALE_getbankstringcount
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
#include <stdlib.h> // for bsearch function
|
||||
|
||||
static int compare ( const void* arg1, const void* arg2 )
|
||||
{
|
||||
const unsigned short* s1 = (const unsigned short*)(arg1);
|
||||
const unsigned short* s2 = (const unsigned short*)(arg2);
|
||||
return (*s1) - (*s2);
|
||||
}
|
||||
|
||||
static int getstringbyindex( unsigned short key, const INDEX* pIndex )
|
||||
{
|
||||
int index = 0;
|
||||
unsigned short* result;
|
||||
unsigned char* base; /* pointer to base of string id table */
|
||||
|
||||
ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
ASSERT(pIndex != NULL); /* index not loaded - .loc file must have index created (use -i option) */
|
||||
|
||||
base = ((unsigned char*)pIndex) + LOCALEFILE_INDEXCHUNK_STRINGID_OFFSET;
|
||||
result = (unsigned short*)bsearch((unsigned char *)&key, base, pIndex->StringCount, 4, compare);
|
||||
|
||||
if (result != NULL) {
|
||||
/* index is the second unsigned short */
|
||||
++result;
|
||||
index = *result;
|
||||
} else {
|
||||
index = -1;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
const char* LOCALE_getstring( int StringID )
|
||||
{
|
||||
const char* p; /* pointer to string, NULL if string cannot be found */
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring::( %d ).", StringID );
|
||||
|
||||
ASSERT( LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */
|
||||
|
||||
/* get string array index from the index if it exists */
|
||||
if ( lx->pIndex[ lx->BankIndex ] != NULL ) {
|
||||
StringID = getstringbyindex((unsigned short)StringID, lx->pIndex[lx->BankIndex]);
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring::( %d ).", StringID );
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring::( lx->BankIndex = %d ).", lx->BankIndex );
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring::( lx->pBank[lx->BankIndex]->StringCount = %d ).", lx->pBank[lx->BankIndex]->StringCount );
|
||||
|
||||
if ((StringID >= 0) && (StringID < (int)(lx->pBank[lx->BankIndex]->StringCount ))) {
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring:: A" );
|
||||
|
||||
unsigned int offset;
|
||||
|
||||
p = (const char*)(lx->pBank[lx->BankIndex]);
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring:: B" );
|
||||
|
||||
offset = *(unsigned int*)(p + LOCALEFILE_LANGUAGECHUNK_STRING_OFFSET + StringID*4);
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring:: C" );
|
||||
|
||||
p += offset;
|
||||
|
||||
Msg( __LINE__, __FILE__, "Locale_getstring:: D" );
|
||||
|
||||
|
||||
} else {
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
Msg( __LINE__, __FILE__, L"%s", 1252, (wchar_t *)p );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
;
|
||||
; ABSTRACT
|
||||
;
|
||||
; LOCALE_getstr - return selected string from the specified .loc file
|
||||
;
|
||||
;
|
||||
; SUMMARY
|
||||
;
|
||||
; #include "realfont.h"
|
||||
;
|
||||
; const char* LOCALE_getstr(stringid)
|
||||
;
|
||||
; int stringid; // string id to return
|
||||
;
|
||||
; DESCRIPTION
|
||||
;
|
||||
; Returns the string identified by stringid from the specified
|
||||
; .loc file. Use the string ID specified in the header file created
|
||||
; by Locomoto. Note that the string pointer is a const pointer. Do
|
||||
; not modify the string or the Locale library may return invalid results.
|
||||
;
|
||||
; If your strings are Unicode strings, cast the result to a const USTR *.
|
||||
;
|
||||
; If the .loc file was created with an index stringid can be any
|
||||
; valid integer in the range 0..65535. If no index was created
|
||||
; with the .loc file stringid will be a zero based array index.
|
||||
;
|
||||
; String is returned by const for a reason. Bad things will happen
|
||||
; if you modify it. You have been warned.
|
||||
;
|
||||
; SEE ALSO
|
||||
;
|
||||
; EXAMPLE
|
||||
;
|
||||
; locale_eg.c
|
||||
;
|
||||
; <HTML A HREF="locale_eg.c">Download the source<HTML /A>
|
||||
; <HTML A HREF="locale_eg.csv">locale_eg.csv<HTML /A> (example data)
|
||||
;
|
||||
; END ABSTRACT
|
||||
;
|
||||
*/
|
||||
|
||||
int LOCALElanguageid = 0;
|
||||
|
||||
const char* LOCALE_getstr( const void* pLocFile, int StringID )
|
||||
{
|
||||
const char* p; /* pointer to string, NULL if string cannot be found */
|
||||
|
||||
HEADER* pHeader;
|
||||
BANK* pBank;
|
||||
|
||||
ASSERT(pLocFile != NULL);
|
||||
|
||||
pHeader = (LOCALEFILE_HEADERCHUNK*)(pLocFile);
|
||||
ASSERT(pHeader->ChunkID == LOCALEFILE_HEADERCHUNKID);
|
||||
ASSERT(pHeader->LanguageCount >= 1);
|
||||
|
||||
if( pHeader->Flags == 1 ) {
|
||||
|
||||
/* file has an index */
|
||||
INDEX* pIndex = (INDEX*)((unsigned char*)(pLocFile) + pHeader->ChunkSize);
|
||||
StringID = getstringbyindex((unsigned short)StringID, pIndex);
|
||||
}
|
||||
|
||||
/* get pointer to string bank */
|
||||
{
|
||||
int offset = *((int*)(pLocFile) + 4 + LOCALElanguageid);
|
||||
pBank = (BANK*)((unsigned char*)(pLocFile) + offset);
|
||||
}
|
||||
|
||||
if ((StringID >= 0) && (StringID < (int)(pBank->StringCount))) {
|
||||
|
||||
unsigned int offset;
|
||||
|
||||
p = (const char*)(pBank);
|
||||
offset = *(unsigned int*)(p + LOCALEFILE_LANGUAGECHUNK_STRING_OFFSET + StringID*4);
|
||||
p += offset;
|
||||
|
||||
} else {
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
72
Generals/Code/Tools/Autorun/locale.h
Normal file
72
Generals/Code/Tools/Autorun/locale.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
** Command & Conquer Generals(tm)
|
||||
** Copyright 2025 Electronic Arts Inc.
|
||||
**
|
||||
** This program is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Copyright (C) Electronic Arts Canada Inc. 1998-1999. All rights reserved. */
|
||||
|
||||
/* ABSTRACT
|
||||
locale.h - REAL fonts
|
||||
@ */
|
||||
|
||||
#ifndef __LOCALE_H
|
||||
#define __LOCALE_H 1
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
//#endif
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* LOCALE API */
|
||||
/****************************************************************************/
|
||||
const char * LOCALE_getstr( const void *localefile, int stringid );
|
||||
/* NOTE: this single function replaces the previous LOCALE API */
|
||||
|
||||
/****************************************************************************/
|
||||
/* OBSOLETE LOCALE API */
|
||||
/****************************************************************************/
|
||||
|
||||
/* This API is being retired in favor of the much simplier single LOCALE_getstr function. */
|
||||
|
||||
#define LOCALE_BANK_COUNT 8
|
||||
|
||||
/* initialization/restore */
|
||||
int LOCALE_init( void ); /* call before calling any other LOCALE functions */
|
||||
void LOCALE_restore( void ); /* free all memory/resources allocated by LOCALE */
|
||||
|
||||
/* attributes */
|
||||
void LOCALE_setbank( int bankindex ); /* bankindex >= 0 && bankindex < LOCALE_BANK_COUNT */
|
||||
int LOCALE_getbank( void ); /* returns current bank id */
|
||||
int LOCALE_getbanklanguageid( void ); /* returns language id of the current bank */
|
||||
int LOCALE_getbankstringcount( void ); /* returns the string string count in the current bank */
|
||||
|
||||
/* operations */
|
||||
int LOCALE_loadtable( const char *pathname, int languageid ); /* load table into the current bank */
|
||||
void LOCALE_freetable( void ); /* free table in the current bank */
|
||||
const char * LOCALE_getstring( int stringid ); /* use values in the .h file created by locomoto */
|
||||
|
||||
/* maintain backwards compatibility */
|
||||
#define LOCALE_purgetable LOCALE_freetable
|
||||
|
||||
|
||||
//#ifdef __cplusplus
|
||||
//}
|
||||
//#endif
|
||||
|
||||
#endif /* __LOCALE_H */
|
||||
/* END ABSTRACT */
|
||||
|
34
Generals/Code/Tools/Autorun/resource.h
Normal file
34
Generals/Code/Tools/Autorun/resource.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by D:\Projects\Renegade\Autorun\English\AUTORUN.RC
|
||||
//
|
||||
#define IDD_OK 100
|
||||
#define IDD_OK2 101
|
||||
#define IDD_REGISTER 102
|
||||
#define IDD_EXPLORE 103
|
||||
#define IDD_CANCEL 104
|
||||
#define IDD_INTERNET 105
|
||||
#define IDD_UNINSTALL 106
|
||||
#define IDD_UPDATE 107
|
||||
#define IDD_NEW_ACCOUNT 108
|
||||
#define IDD_VIEW_DEMO 109
|
||||
#define IDD_GAMESPY 110
|
||||
#define IDD_OK3 111
|
||||
#define IDD_OK4 112
|
||||
#define IDD_PREVIEWS 113
|
||||
#define IDD_HELP 114
|
||||
|
||||
|
||||
#define IDS_VERSION_STRING 120
|
||||
#define IDS_CANT_FIND_FILE 121
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 117
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
Reference in a new issue