mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Added missing #includes Added LUA scripting and console Changed the way tracers are visualized, so they work more like real tracers instead of a light fountain Fixed signedness of many grid variables used in GetMouseMapPos calls Fixed enemy weapon choosing: Sometimes a mortar is chosen but later rejected, but the grenade class was not reset. Caused assertion failure Added checks so enemies don't try to chuck RPG grenades with their hands Now possible to shoot a someone in the head if he's in water Fixed InitSightArrays to also clear soldier interrupt duel points. This was causing an assertion failure elsewhere in the code because the interrupt list still had soldiers on it sometimes when this function was called. Soldiers are much less willing to forfeit their turn over an attempt to use more APs than they have Removed early setting of muzzle flash. This would allow enemies to get an interrupt before you even fired. Fixed item dropping by AI. If AI tried to drop something while standing it would cause deadlock Change to greatly speed up closing the sector inventory window in an unloaded sector Added conditional compile flag to always give robot weapon ready advantage, even for 360 degree sighting Check builddefines.h for the conditional flags. Of greatest interest might be LUA_CONSOLE. This will cause the game to bring up a command console when run. However this console is severely lacking in many areas. If anybody knows of an open-source terminal/console that could be used instead, it would be appreciated. The existing console does bad things when you try to close it, and since it counts as a separate app, it pauses the game while it has focus. LUA scripting is very limited, basically just proof of concept. There is one global variable, the Soldiers array. An array index gives you the soldier in that slot in the currently loaded sector. The soldier has a few things that can be accessed: name (short name); fullname (long name); grid (current grid #, can be changed); walkto(grid) (function to walk to another grid); runto(grid) (function to run to another grid) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@924 3b4a5df2-a311-0410-b5c6-a8a6f20db521
161 lines
5.1 KiB
C++
161 lines
5.1 KiB
C++
/*
|
|
MULTILINGUAL TEXT CODE GENERATOR
|
|
This code generator is used to conveniently compare the english master text file with another foreign language
|
|
such as German and verify that the appropriate language file is in perfect synch with the English. Verifying
|
|
that all of the strings have the correct order of printf format specifiers and the precise number. If
|
|
different, the errors are recorded via comments proceeding the string in question in the new file. For
|
|
simplicity, the German language will be used in examples throughout this documention. The comments will be
|
|
specially marked with "CONFLICT#xxx: error message" which can be searched for. The comment will report
|
|
the format specifiers used in the english version.
|
|
|
|
ASSUMPTIONS
|
|
- No functions exist in any of the master files
|
|
- Users don't use single strings using:
|
|
STR16 str[] = L"Single String";
|
|
Instead use:
|
|
STR16 str[] =
|
|
{
|
|
L"Single String";
|
|
}
|
|
- Users don't use comments containing the { character later followed by the L" token. The code generator
|
|
will mistaken that for a string.
|
|
- Users don't use nested braces (2D text arrays)
|
|
|
|
|
|
|
|
AUTHOR: Kris Morness
|
|
CREATED: Feb 16, 1999
|
|
*/
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#include "builddefines.h"
|
|
#include <stdio.h>
|
|
#include "types.h"
|
|
#include "Language Defines.h"
|
|
#include "debug.h"
|
|
#include "Fileman.h"
|
|
|
|
//Currently in JA2's _EnglishText, these tokens make up all of the
|
|
//format specifiers that are actually used. Feel free to add more,
|
|
//but make sure you change NUM_TOKENS accordingly. These tokens assume
|
|
//the previous character is a % character.
|
|
UINT8 SupportedTokens[] =
|
|
{
|
|
'd',
|
|
'c',
|
|
's',
|
|
'S',
|
|
'%',
|
|
};
|
|
#define NUM_TOKENS 5
|
|
|
|
enum
|
|
{
|
|
//look for { character followed by L" before } to upgrade to INSIDE_STRING
|
|
OUTSIDE_STRING_ARRAY,
|
|
|
|
//look for } character to downgrade to OUTSIDE_STRING_ARRAY
|
|
//look for L" characters to upgrade to INSIDE_STRING
|
|
INSIDE_STRING_ARRAY,
|
|
|
|
//look for " character to downgrade to INSIDE_STRING_ARRAY
|
|
INSIDE_STRING,
|
|
};
|
|
|
|
//Specifies where the master english file is located relative to the exe directory
|
|
#define LCG_WORKINGDIRECTORY "build\\utils"
|
|
#define LCG_ENGLISHMASTERFILE "_EnglishText.c"
|
|
|
|
//The commandline argument (add different one for each language supported
|
|
//***Only one can exist at a time and it is controlled by Language Defines.h )
|
|
#define LCG_COMMANDLINEARGUMENT "-GERMAN"
|
|
#define LCG_FOREIGNMASTERFILE "_GermanText.c"
|
|
#define LCG_FOREIGNNEWFILE "_NewGermanText.c"
|
|
|
|
//Given a file pointer, searches for the next DB string
|
|
UINT32 CountDoubleByteStringsInFile( STR8 filename );
|
|
|
|
|
|
//One function does it all. First looks for the cmd line arg, and if it matches
|
|
//the above define, searches for the files, and processes them automatically.
|
|
BOOLEAN ProcessIfMultilingualCmdLineArgDetected( STR8 str )
|
|
{
|
|
STRING512 ExecDir;
|
|
STRING512 CurrDir;
|
|
STRING512 Dir;
|
|
UINT32 uiEnglishStrings, uiForeignStrings;
|
|
|
|
//check if command line argument matches the LCG's
|
|
if( strcmp( str, LCG_COMMANDLINEARGUMENT ) )
|
|
{ //string is different, so return
|
|
return FALSE;
|
|
}
|
|
|
|
//Record the exe directory
|
|
GetExecutableDirectory( ExecDir );
|
|
//Record the curr directory used (we will restore before leaving)
|
|
GetFileManCurrentDirectory( CurrDir );
|
|
|
|
//Build the working directory name
|
|
sprintf( Dir, "%s\\%s", ExecDir, LCG_WORKINGDIRECTORY );
|
|
|
|
//Set the working directory
|
|
if( !SetFileManCurrentDirectory( Dir ) )
|
|
{ //We failed meaning the directory name is incorrect or non-existant
|
|
AssertMsg( 0, "Failed to set directory location while attempting to activate multilingual text code generator." );
|
|
return FALSE;
|
|
}
|
|
|
|
//verify that all files exist
|
|
if( !FileExists( LCG_ENGLISHMASTERFILE ) )
|
|
{
|
|
AssertMsg( 0, "Failed to find master english file while attempting to activate multilingual text code generator." );
|
|
return FALSE;
|
|
}
|
|
if( !FileExists( LCG_FOREIGNMASTERFILE ) )
|
|
{
|
|
AssertMsg( 0, "Failed to find master foreign file while attempting to activate multilingual text code generator." );
|
|
return FALSE;
|
|
}
|
|
|
|
//ALL PRELIMINARY CHECKS HAVE SUCCEEDED.
|
|
//Begin file preparation checks...
|
|
|
|
//STEP1: Read the English master file and count the number of DB strings that exist
|
|
uiEnglishStrings = CountDoubleByteStringsInFile( LCG_ENGLISHMASTERFILE );
|
|
|
|
//STEP2: Read the Foreigh master file and count the number of DB strings that exist
|
|
uiForeignStrings = CountDoubleByteStringsInFile( LCG_FOREIGNMASTERFILE );
|
|
|
|
//Make sure they match, otherwise, we can't continue.
|
|
if( uiEnglishStrings != uiForeignStrings )
|
|
{
|
|
AssertMsg( 0, String( "Mismatch during LCG preparation: English DB strings: %d, Foreign DB strings: %d",
|
|
uiEnglishStrings, uiForeignStrings ) );
|
|
return FALSE;
|
|
}
|
|
|
|
//Mission complete! Reset the previously known directory, and return TRUE;
|
|
SetFileManCurrentDirectory( CurrDir );
|
|
return TRUE;
|
|
}
|
|
|
|
UINT32 CountDoubleByteStringsInFile( STR8 filename )
|
|
{
|
|
FILE *fp = NULL;
|
|
UINT32 uiNumStrings = 0;
|
|
|
|
//open file
|
|
fp = fopen( filename, "r" );
|
|
if( !fp )
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
fclose( fp );
|
|
return uiNumStrings;
|
|
}
|
|
|
|
#endif //_DEBUG
|