1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
#include "ai/ai.h"
#include "loaders.h"
#include "dlg_box.h"
#include "dlg_box.h"
#include "strtmesg.h"
#include "sg.h"
#include "viewcalculation.h"
#include "replay.h"
#include "messagedlg.h"
#include "researchexecution.h"
#include "resourcenet.h"
#include "mapimageexport.h"
#include "soundList.h"
#include "turncontrol.h"
#include "stdio-errorhandler.h"
#include "autotraining.h"
#include "actiontest.h"
#include "movementtest.h"
#include "attacktest.h"
#include "ai-move1.h"
#include "viewtest.h"
#include "ai-service1.h"
#include "transfercontroltest.h"
#include "recyclingtest.h"
#include "researchtest.h"
#include "applicationstarter.h"
#include "diplomacytest.h"
#include "objectconstructiontest.h"
#include "eventtest.h"
#include "gameeventsystem.h"
#include "jumptest.h"
#include "testversionidentifier.h"
void viewcomp( Player& player )
{
computeview( player.getParentMap() );
}
void hookGuiToMap( GameMap* map )
{
if ( !map->getGuiHooked() ) {
map->sigPlayerUserInteractionBegins.connect( SigC::slot( &viewcomp ) );
map->sigPlayerUserInteractionBegins.connect( SigC::hide<Player&>( repaintMap.slot() ));
map->sigPlayerUserInteractionBegins.connect( SigC::hide<Player&>( SigC::slot( &checkforreplay )));
map->sigPlayerUserInteractionBegins.connect( SigC::slot( &viewunreadmessages ));
map->sigPlayerUserInteractionBegins.connect( SigC::slot( &checkJournal ));
map->sigPlayerUserInteractionBegins.connect( SigC::slot( &checkUsedASCVersions ));
map->sigPlayerUserInteractionBegins.connect( SigC::hide<Player&>( updateFieldInfo.slot() ));
map->sigPlayerTurnHasEnded.connect( SigC::slot( viewOwnReplay));
map->guiHooked();
}
}
bool loadGameFromFile( const ASCString& filename )
{
return false;
}
Context createContext( GameMap* gamemap )
{
Context context;
context.gamemap = gamemap;
context.actingPlayer = &gamemap->getPlayer( gamemap->actplayer );
context.parentAction = NULL;
context.display = &getDefaultMapDisplay();
context.viewingPlayer = gamemap->getPlayerView();
context.actionContainer = &gamemap->actions;
return context;
}
void runUnitTests()
{
testVersionIdentifier();
testJumpdrive();
testEvents();
testActions();
testObjectConstruction();
testResearch();
testDiplomacy();
testRecycling();
testTransferControl();
testAiService();
testMovement();
testAttack();
testAiMovement();
testView();
}
void checkGameEvents( GameMap* map,const Command& command )
{
checktimedevents( map, NULL );
checkevents( map, NULL );
}
int runTester ( )
{
loadpalette();
virtualscreenbuf.init();
try {
loaddata();
}
catch ( ParsingError err ) {
errorMessage ( "Error parsing text file " + err.getMessage() );
return -1;
}
catch ( tfileerror err ) {
errorMessage ( "Error loading file " + err.getFileName() );
return -1;
}
catch ( ASCexception ) {
errorMessage ( "loading of game failed" );
return -1;
}
catch ( ThreadExitException ) {
displayLogMessage(0, "caught thread exiting exception, shutting down");
return -1;
}
#ifndef _WIN32_
// Windows/MSVC will catch access violations with this, which we don't want to, because it makes our dump files useless.
catch ( ... ) {
fatalError ( "caught undefined exception" );
return -1;
}
#endif
GameMap::sigPlayerTurnEndsStatic.connect( SigC::slot( automaticTrainig ));
//ActionContainer::postActionExecution.connect( SigC::slot( &checkGameEvents ));
suppressMapTriggerExecution = false;
runUnitTests();
return 0;
}
static void __runResearch( Player& player ){
runResearch( player, NULL, NULL );
}
void deployMapPlayingHooks ( GameMap* map )
{
map->sigPlayerTurnBegins.connect( SigC::slot( initReplayLogging ));
map->sigPlayerTurnBegins.connect( SigC::slot( transfer_all_outstanding_tribute ));
map->sigPlayerTurnBegins.connect( SigC::slot( __runResearch ));
}
// including the command line parser, which is generated by genparse
#include "clparser/asc.cpp"
void execuseraction ( tuseractions action ) {};
void execUserAction_ev ( tuseractions action ) {};
int main(int argc, char *argv[] )
{
assert ( sizeof(PointerSizedInt) == sizeof(int*));
// we should think about replacing clparser with libpopt
Cmdline* cl = NULL;
try {
cl = new Cmdline ( argc, argv );
} catch ( string s ) {
cerr << s;
exit(1);
}
auto_ptr<Cmdline> apcl ( cl );
if ( cl->v() ) {
ASCString msg = getstartupmessage();
printf( msg.c_str() );
exit(0);
}
if ( cl->w() )
fullscreen = SDL_FALSE;
if ( cl->f() )
fullscreen = SDL_TRUE;
MessagingHub::Instance().setVerbosity( cl->r() );
StdIoErrorHandler stdIoErrorHandler(false);
MessagingHub::Instance().exitHandler.connect( SigC::bind( SigC::slot( exit_asc ), -1 ));
#ifdef WIN32
Win32IoErrorHandler* win32ErrorDialogGenerator = new Win32IoErrorHandler;
#endif
ConfigurationFileLocator::Instance().setExecutableLocation( argv[0] );
initFileIO( cl->c() ); // passing the filename from the command line options
SoundSystem soundSystem ( true, true, true );
tspfldloaders::mapLoaded.connect( SigC::slot( deployMapPlayingHooks ));
PG_FileArchive archive( argv[0] );
try {
runTester();
}
catch ( bad_alloc ) {
fatalError ("Out of memory");
return 1;
}
catch ( ASCmsgException e ) {
cerr << e.getMessage() << "\n";
return 2;
}
catch ( ActionResult ar ) {
cerr << "ActionResult failed:" << ar.getCode() << " : " << ar.getMessage() << "\n";
return 2;
}
catch ( ... ) {
cerr << "caught exception\n";
return 2;
}
cout << "exiting successfully \n";
return 0;
}
|