int main(int argc, char **argv) { int err = 0; lua_State *L; setup_signal_handler(); /* parse args once to read config file location */ if (parse_args(argc, argv, &err) != 0) { return err; } /* ini file sets defaults for arguments*/ parse_config(inifile); if (!global.inifile) { log_error("could not open ini configuration %s\n", inifile); } /* parse arguments again, to override ini file */ parse_args(argc, argv, &err); log_open(logfile); locale_init(); #ifdef CRTDBG init_crtdbg(); #endif L = lua_init(); game_init(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("script %s failed with code %d\n", luafile, err); return err; } #ifdef MSPACES malloc_stats(); #endif game_done(); lua_done(L); log_close(); if (global.inifile) { iniparser_freedict(global.inifile); } return 0; }
int HandleAppEvents(void *userdata, SDL_Event *event) { switch (event->type) { case SDL_APP_LOWMEMORY: return 0; case SDL_APP_WILLENTERBACKGROUND: /* Prepare your app to go into the background. Stop loops, etc. This gets called when the user hits the home button, or gets a call. */ return 0; case SDL_APP_DIDENTERBACKGROUND: /* This will get called if the user accepted whatever sent your app to the background. If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. When you get this, you have 5 seconds to save all your state or the app will be terminated. Your app is NOT active at this point. */ /* snd_pause(1); */ m_minimized = 1; return 0; case SDL_APP_WILLENTERFOREGROUND: /* This call happens when your app is coming back to the foreground. Restore all your state here. */ return 0; case SDL_APP_DIDENTERFOREGROUND: /* Restart your loops here. Your app is interactive and getting CPU again. */ /* snd_pause(0); */ m_minimized = 0; return 0; case SDL_APP_TERMINATING: cfg_save(); game_done(0); gfx_video_done(); gfx_done(); return 0; default: /* No special processing, add it to the event queue */ return 1; } }
int main(int argc, char **argv) { int err, result = 0; lua_State *L; setup_signal_handler(); parse_config(inifile); log_open(logfile); err = parse_args(argc, argv, &result); if (err) { return result; } locale_init(); #ifdef CRTDBG init_crtdbg(); #endif L = lua_init(); game_init(); register_races(); register_borders(); register_spells(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("server execution failed with code %d\n", err); return err; } #ifdef MSPACES malloc_stats(); #endif game_done(); lua_done(L); log_close(); if (global.inifile) { iniparser_free(global.inifile); } return 0; }
int main(int argc, char **argv) { int err = 0; lua_State *L; dictionary *d = 0; setup_signal_handler(); message_handle_missing(MESSAGE_MISSING_REPLACE); /* parse arguments again, to override ini file */ err = parse_args(argc, argv); if (err != 0) { return (err > 0) ? 0 : err; } d = parse_config(inifile); if (!d) { log_error("could not open ini configuration %s\n", inifile); } locale_init(); L = lua_init(d); game_init(); bind_monsters(L); err = eressea_run(L, luafile); if (err) { log_error("script %s failed with code %d\n", luafile, err); return err; } game_done(); lua_done(L); log_close(); stats_write(stdout, ""); stats_close(); if (d) { iniparser_freedict(d); } return 0; }
int main() { if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK ) < 0 ) { SYS_BREAK( "SDL_Init failed!\n" ); } SDL_SetVideoMode( ScreenWidth, ScreenHeight, 0u, SDL_OPENGL /*| SDL_FULLSCREEN */ ); #ifndef FONT_EDITOR SDL_ShowCursor( SDL_DISABLE ); #endif SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ); SDL_AudioSpec audioSpec; audioSpec.freq = SoundSampleRate; audioSpec.format = AUDIO_S16SYS; audioSpec.channels = SoundChannelCount; audioSpec.silence = 0; audioSpec.samples = SoundBufferSampleCount; audioSpec.size = 0; audioSpec.callback = soundCallback; audioSpec.userdata = s_soundBuffer; SDL_OpenAudio( &audioSpec, NULL ); game_init(); SDL_PauseAudio( 0 ); uint32 lastTime = SDL_GetTicks(); uint32 buttonMask = 0u; uint32 joystickButtonMask = 0u; #ifndef SYS_BUILD_MASTER uint32 lastTimingTime = lastTime; uint32 timingFrameCount = 0u; #endif SDL_JoystickEventState( SDL_ENABLE ); SDL_Joystick* pJoystick0 = SDL_JoystickOpen( 0 ); SYS_USE_ARGUMENT(pJoystick0); int16 joystickAxis0 = 0; int16 joystickAxis1 = 0; float2 mousePos; float2_set(&mousePos, 0.0f, 0.0f); int leftMouseDown=0; int leftMousePressed=0; int rightMouseDown=0; int rightMousePressed=0u; int quit = 0; do { uint32 currentTime = SDL_GetTicks(); const float timeStep = ( float )( currentTime - lastTime ) / 1000.0f; lastTime = currentTime; #ifndef SYS_BUILD_MASTER if( currentTime - lastTimingTime > 500u ) { const float timingTimeSpan = ( float )( currentTime - lastTimingTime ) / 1000.0f; const float currentFps = ( float )( timingFrameCount ) / timingTimeSpan; char windowTitle[ 100u ]; sprintf( windowTitle, "fps=%f cb=%i", currentFps, s_callbackCount ); SDL_WM_SetCaption( windowTitle, 0 ); lastTimingTime = currentTime; timingFrameCount = 0u; } #endif // get local user input: SDL_Event event; while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_JOYAXISMOTION: if( event.jaxis.axis == 0u ) { joystickAxis0 = event.jaxis.value; } else if( event.jaxis.axis == 1u ) { joystickAxis1 = event.jaxis.value; } break; case SDL_JOYBUTTONDOWN: if( event.jbutton.button == 0 ) { updateButtonMask( &joystickButtonMask, ButtonMask_PlaceBomb, 1 ); } break; case SDL_JOYBUTTONUP: if( event.jbutton.button == 0 ) { updateButtonMask( &joystickButtonMask, ButtonMask_PlaceBomb, 0 ); } break; case SDL_MOUSEMOTION: float2_set(&mousePos, (float)event.motion.x, (float)event.motion.y); break; case SDL_MOUSEBUTTONDOWN: SYS_TRACE_DEBUG("down=%i\n", event.button.button); if( event.button.button == 1 ) { leftMouseDown = 1; leftMousePressed = 1; } else if( event.button.button == 3) { rightMouseDown = 1; rightMousePressed = 1; } break; case SDL_MOUSEBUTTONUP: if(event.button.button == 1) { leftMouseDown = 0; } else if(event.button.button == 3) { rightMouseDown = 0; } break; case SDL_KEYDOWN: case SDL_KEYUP: { const int ctrlPressed = ( event.key.keysym.mod & KMOD_CTRL ) != 0; switch( event.key.keysym.sym ) { case SDLK_ESCAPE: quit = 1; break; case SDLK_LEFT: updateButtonMask( &buttonMask, ctrlPressed ? ButtonMask_CtrlLeft : ButtonMask_Left, event.type == SDL_KEYDOWN ); break; case SDLK_RIGHT: updateButtonMask( &buttonMask, ctrlPressed ? ButtonMask_CtrlRight : ButtonMask_Right, event.type == SDL_KEYDOWN ); break; case SDLK_UP: updateButtonMask( &buttonMask, ctrlPressed ? ButtonMask_CtrlUp : ButtonMask_Up, event.type == SDL_KEYDOWN ); break; case SDLK_DOWN: updateButtonMask( &buttonMask, ctrlPressed ? ButtonMask_CtrlDown : ButtonMask_Down, event.type == SDL_KEYDOWN ); break; case SDLK_SPACE: updateButtonMask( &buttonMask, ButtonMask_PlaceBomb, event.type == SDL_KEYDOWN ); break; case SDLK_c: updateButtonMask( &buttonMask, ButtonMask_Client, event.type == SDL_KEYDOWN ); break; case SDLK_s: updateButtonMask( &buttonMask, ButtonMask_Server, event.type == SDL_KEYDOWN ); break; case SDLK_l: updateButtonMask( &buttonMask, ButtonMask_Leave, event.type == SDL_KEYDOWN ); break; default: break; } } break; case SDL_QUIT: quit = 1; break; } } updateButtonMaskFromJoystick( &joystickButtonMask, ButtonMask_Right, joystickAxis0, 16000 ); updateButtonMaskFromJoystick( &joystickButtonMask, ButtonMask_Left, -joystickAxis0, 16000 ); updateButtonMaskFromJoystick( &joystickButtonMask, ButtonMask_Down, joystickAxis1, 3200 ); updateButtonMaskFromJoystick( &joystickButtonMask, ButtonMask_Up, -joystickAxis1, 3200 ); #ifdef FONT_EDITOR static uint currentChar = '0'; static uint dataChar = '\0'; static float2 charPoints[ 128u ]; static uint charPointCount = 0u; static uint32 lastButtonMask = 0u; static int currentPointIndex = -1; static float2 oldMousePagePos; const uint32 buttonPressMask = buttonMask & ~lastButtonMask; lastButtonMask = buttonMask; float2 mousePagePos; mousePagePos.x=64.0f*mousePos.x/(float)ScreenWidth; mousePagePos.y=36.0f+-36.0f*mousePos.y/(float)ScreenHeight; if( buttonPressMask & ButtonMask_Right ) { currentChar=font_getNextGlyphCharCode(currentChar,1); } if( buttonPressMask & ButtonMask_Left ) { currentChar=font_getNextGlyphCharCode(currentChar,-1); } if( currentChar != dataChar ) { if( dataChar != '\0' ) { char filename[128u]; sprintf(filename,"./source/font/char_%i.h",dataChar); SYS_TRACE_DEBUG("writing char to file '%s'\n", filename); FILE* pFile=fopen(filename, "w"); if(pFile) { fprintf(pFile,"static const float2 s_points_%i[] =\n{\n",dataChar); for( uint i=0u;i<charPointCount;++i) { fprintf(pFile,"\t{%ff,%ff},\n",charPoints[i].x,charPoints[i].y); } fprintf(pFile,"};\n\n"); fclose(pFile); } else { SYS_TRACE_ERROR("Could not open file '%s'\n", filename); } } const FontGlyph* pGlyph=font_getGlyph((uint)currentChar); if(pGlyph) { charPointCount = uint_min(SYS_COUNTOF(charPoints),pGlyph->pointCount); memcpy(charPoints,pGlyph->pPoints,charPointCount*sizeof(float2)); dataChar = currentChar; } else { charPointCount = 0u; } currentPointIndex = -1; } if( dataChar && ( buttonPressMask & ButtonMask_Down ) ) { // add a point: if(charPointCount>0) { charPointCount--; } } if( dataChar && ( buttonPressMask & ButtonMask_Up ) ) { // add a point: if(charPointCount<SYS_COUNTOF(charPoints)) { float2_set(&charPoints[charPointCount],0.0f,0.0f); charPointCount++; } } if( renderer_isPageDone() ) { // new page: renderer_flipPage(); renderer_setPen( Pen_Font ); /* const float2 worldOffset = { 32.0f, 16.0f }; const float2 position = { 0.0f, 0.0f };*/ renderer_setVariance( 0.0f ); renderer_setTransform( 0 ); const float fontSize=3.0f; float2 textPos; float2_set(&textPos,32.0f,16.0f); if( charPointCount > 0u ) { float2x3 transform; float2x2_identity(&transform.rot); float2x2_scale1f(&transform.rot,&transform.rot,fontSize); transform.pos=textPos; renderer_setTransform( &transform ); renderer_addQuadraticStroke(charPoints,charPointCount); transform.pos.x -= 10.0f; renderer_setTransform( &transform ); renderer_addQuadraticStroke(charPoints,charPointCount); } // draw control points: const float cpSize=0.5f; int inRangePoint=-1; for(uint i = 0u; i < charPointCount; ++i) { float2 pos; float2_set(&pos,32.0f,16.0f); float2_addScaled1f(&pos,&pos,&charPoints[i],fontSize); const int inRange = float2_distance(&mousePagePos,&pos)<cpSize; if( inRange && inRangePoint==-1) { inRangePoint=(int)i; } if(currentPointIndex==-1&&inRange&&leftMousePressed) { currentPointIndex=(int)i; } else if(currentPointIndex!=-1) { if(!leftMouseDown) { currentPointIndex=-1; } else if( currentPointIndex==(int)i ) { // move cp to be under the mouse cursor: float2 newCpPos; float2_sub(&newCpPos,&mousePagePos,&textPos); float2_scale1f(&charPoints[i],&newCpPos,1.0f/fontSize); } } float3 color; if((int)i==currentPointIndex) { float3_set(&color,0.2f,1.0f,0.2f); } else if(inRange) { float3_set(&color,0.5f,0.5f,0.2f); } else { float3_set(&color,0.8f,0.2f,0.2f); } renderer_drawCircle(&pos,cpSize,&color); } oldMousePagePos=mousePagePos; leftMousePressed=0; rightMousePressed=0; float2_set(&textPos,5.0f,4.0f); font_drawText(&textPos,1.0f,0.0f,"0123456789A" ); } renderer_updatePage( timeStep ); FrameData frame; //memset( &frame, 0u, sizeof( frame ) ); //frame.time = s_game.gameTime; //frame.playerPos = s_game.player[ 0u ].position; renderer_drawFrame( &frame ); #elif defined( TEST_RENDERER ) if( renderer_isPageDone() ) { // new page: renderer_flipPage(); /*float2 points[] = { { -4.0f, 0.0f }, { -4.0f, -4.0f }, { 0.0f, -4.0f }, { 4.0f, -4.0f }, { 4.0f, 0.0f }, { 4.0f, 4.0f }, { 0.0f, 4.0f }, { -4.0f, 4.0f }, { -4.0f, 0.0f } { -0.2f, 1.0f } };*/ renderer_setPen( Pen_DebugGreen ); const float2 worldOffset = { 32.0f, 16.0f }; const float2 position = { 0.0f, 0.0f }; float2x3 bombTransform; float2x2_rotationY( &bombTransform.rot, 0.0f ); float2x2_scale1f( &bombTransform.rot, &bombTransform.rot, 1.0f ); float2_add( &bombTransform.pos, &position, &worldOffset ); renderer_setTransform( &bombTransform ); //renderer_addQuadraticStroke(&points[0u],&points[1u],&points[2u]); //renderer_addQuadraticStroke(points,SYS_COUNTOF(points)); float2 textPos; float2_set(&textPos,5.0f,4.0f); font_drawText(&textPos,2.0f,0.0f,"P"); } renderer_updatePage( timeStep ); FrameData frame; //memset( &frame, 0u, sizeof( frame ) ); //frame.time = s_game.gameTime; //frame.playerPos = s_game.player[ 0u ].position; renderer_drawFrame( &frame ); #else renderer_setVariance(0.0f); GameInput gameInput; memset( &gameInput, 0u, sizeof( gameInput ) ); gameInput.timeStep = timeStep; gameInput.buttonMask = buttonMask | joystickButtonMask; game_update( &gameInput ); game_render(); #endif SDL_GL_SwapBuffers(); #ifndef SYS_BUILD_MASTER timingFrameCount++; #endif } while( !quit ); // :TODO: nicer fade out.. SDL_PauseAudio( 1 ); game_done(); }
int main(int argc, char *argv[]) { #ifdef _USE_UNPACK int clean_tmp = 0; #endif int err = 0; int i; #ifdef __APPLE__ macosx_init(); #endif #ifndef S60 putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */ #endif #ifdef _WIN32_WCE libwince_init(argv[0], 1); wince_init(argv[0]); #else #ifdef S60 extern char s60_data[]; strcpy(game_cwd, s60_data); #else #ifdef _WIN32 strcpy(game_cwd, dirname(argv[0])); #else if (!getcwd(game_cwd, sizeof(game_cwd))) fprintf(stderr,"Warning: can not get current dir\n."); #endif #endif #endif unix_path(game_cwd); setdir(game_cwd); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-vsync")) vsync_sw = 1; else if (!strcmp(argv[i], "-nosound")) nosound_sw = 1; else if (!strcmp(argv[i], "-fullscreen")) fullscreen_sw = 1; else if (!strcmp(argv[i], "-mode")) { if ((i + 1) < argc) mode_sw = argv[++i]; else mode_sw = "-1x-1"; } else if (!strcmp(argv[i], "-window")) window_sw = 1; else if (!strcmp(argv[i], "-debug")) { if (!debug_sw) debug_init(); debug_sw = 1; } else if (!strcmp(argv[i], "-owntheme")) owntheme_sw = 1; else if (!strcmp(argv[i], "-noautosave")) noauto_sw = 1; else if (!strcmp(argv[i], "-game")) { if ((i + 1) < argc) game_sw = argv[++i]; else game_sw = ""; } else if (!strcmp(argv[i], "-theme")) { if ((i + 1) < argc) theme_sw = argv[++i]; else theme_sw = ""; } else if (!strcmp(argv[i], "-nostdgames")) { nostdgames_sw = 1; #ifdef _LOCAL_APPDATA } else if (!strcmp(argv[i], "-appdata")) { if ((i + 1) < argc) appdata_sw = argv[++i]; else appdata_sw = ""; #endif } else if (!strcmp(argv[i], "-chunksize")) { if ((i + 1) < argc) chunksize_sw = atoi(argv[++i]); else chunksize_sw = DEFAULT_CHUNKSIZE; } else if (!strcmp(argv[i], "-gamespath")) { if ((i + 1) < argc) games_sw = argv[++i]; else games_sw = ""; } else if (!strcmp(argv[i], "-themespath")) { if ((i + 1) < argc) themes_sw = argv[++i]; else themes_sw = ""; } else if (!strcmp(argv[i], "-idf")) { if ((i + 1) < argc) idf_sw = argv[++i]; else { fprintf(stderr,"No data directory specified.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-encode")) { if ((i + 1) < argc) encode_sw = argv[++i]; else { fprintf(stderr,"No lua file specified.\n"); err = 1; goto out; } if ((i + 1) < argc) encode_output = argv[++i]; else encode_output = "lua.enc"; } else if (!strcmp(argv[i], "-version")) { version_sw = 1; } else if (!strcmp(argv[i], "-nopause")) { nopause_sw = 1; } else if (!strcmp(argv[i], "-software")) { software_sw = 1; #ifdef _USE_UNPACK } else if (!strcmp(argv[i], "-install")) { if ((i + 1) < argc) { char *file = argv[++i]; char *p; if (games_sw) p = games_sw; else p = game_local_games_path(1); if (setup_zip(file, p)) { err = 1; goto out; } } #endif } else if (!strcmp(argv[i], "-quit")) { exit(0); } else if (!strcmp(argv[i], "-hinting")) { if ((i + 1) < argc) hinting_sw = atoi(argv[++i]); else hinting_sw = 1; } else if (!strcmp(argv[i], "-lua") || !strcmp(argv[i], "-luac")) { if ((i + 1) < argc) { lua_exec = !strcmp(argv[i], "-lua"); lua_sw = argv[++ i]; opt_index = i + 1; break; } else { fprintf(stderr, "No lua script.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { usage(); goto out; } else if (argv[i][0] == '-') { fprintf(stderr,"Unknown option: %s\n", argv[i]); usage(); err = 1; goto out; } else if (!start_idf(argv[i])) { fprintf(stderr, "Adding idf: %s\n", argv[i]); } else if (!run_game(argv[i])) { fprintf(stderr, "Opening game: %s\n", argv[i]); } #ifdef _USE_UNPACK else { char *p; if (games_sw) p = games_sw; else p = game_tmp_path(); if (setup_zip(argv[i], p)) { err = 1; goto out; } clean_tmp = 1; } #endif } cfg_load(); if (opt_debug == 1 && debug_sw == 0) { debug_sw = 1; debug_init(); } if (opt_vsync == 1 && vsync_sw == 0) vsync_sw = 1; if (version_sw) { fprintf(stdout, VERSION"\n"); goto out; } if (lua_sw) { err = instead_init_lua(dirname(lua_sw)); if (err) goto out; if (!err) err = instead_loadscript(lua_sw, argc - opt_index, argv + opt_index, lua_exec); instead_done(); goto out; } if (encode_sw) { err = instead_encode(encode_sw, encode_output); goto out; } if (idf_sw) { char *p = malloc(strlen(idf_sw) + 5); if (p) { char *b; strcpy(p, idf_sw); b = basename(p); strcat(b, ".idf"); idf_create(b, idf_sw); free(p); } else idf_create("data.idf", idf_sw); goto out; } menu_langs_lookup(dirpath(LANG_PATH)); if (!langs_nr) { fprintf(stderr, "No languages found in: %s.\n", dirpath(LANG_PATH)); err = 1; goto out; } if (!opt_lang || !opt_lang[0]) opt_lang = game_locale(); if (menu_lang_select(opt_lang) && menu_lang_select(LANG_DEF)) { fprintf(stderr, "Can not load default language.\n"); err = 1; goto out; } if (games_sw) games_lookup(games_sw); if (owntheme_sw && !opt_owntheme) { opt_owntheme = 2; } if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH))) fprintf(stderr, "No games found in: %s.\n", GAMES_PATH); if (themes_sw) themes_lookup(themes_sw); if (!nostdthemes_sw) { themes_lookup(dirpath(THEMES_PATH)); themes_lookup(game_local_themes_path()); } if (!nostdgames_sw) games_lookup(game_local_games_path(0)); if (start_idf_sw) { char *d, *b; char *dd, *bb; static char idf_game[255]; d = strdup(start_idf_sw); b = strdup(start_idf_sw); if (d && b) { dd = dirname(d); bb = basename(b); if (!games_replace(dirpath(dd), bb)) { game_sw = idf_game; strncpy(idf_game, bb, sizeof(idf_game) - 1); idf_game[sizeof(idf_game) - 1] = 0; } } if (d) free(d); if (b) free(b); } if (noauto_sw && opt_autosave) opt_autosave = 2; if (window_sw) opt_fs = 0; if (fullscreen_sw) opt_fs = 1; if (mode_sw) parse_mode(mode_sw, opt_mode); if (game_sw) { FREE(opt_game); opt_game = game_sw; } if (theme_sw) { FREE(opt_theme); opt_theme = theme_sw; } if (opt_theme) game_theme_select(opt_theme); if (!curtheme_dir) game_theme_select(DEFAULT_THEME); /* Initialize SDL */ if (gfx_init() < 0) return -1; #ifdef _USE_GTK gtk_init(&argc, &argv); /* must be called AFTER SDL_Init when using SDL2 */ #endif if (gfx_video_init() || input_init()) return -1; if (game_init(opt_game)) { game_error(); } game_loop(); cfg_save(); game_done(0); gfx_video_done(); #ifndef ANDROID gfx_done(); #endif out: if (debug_sw) debug_done(); #ifdef _USE_GTK /* gtk_main_quit (); */ #endif #ifdef _USE_UNPACK if (clean_tmp) remove_dir(game_tmp_path()); #endif #if defined(ANDROID) || defined(IOS) exit(err); #endif return err; }
void return_a_card(SDL_Renderer *pRenderer,SDL_Texture *back_face_texture, int *sleep, int16_t *counter) { /** Implement an animation wenn the player return an card. */ if (*counter == 0) { /** This is the first time the function is executed. * So we change the mainloop pausing time, * set the cursor to an wait cursor * and the game status is set on playing an animation. ******************************************************/ *sleep=5000 ; game_control->is_animation_running=true ; game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAITARROW) ; SDL_SetCursor(game_control->cursor_type) ; current_card->is_moving=true ; } (*counter)++ ; SDL_Texture *image_to_display ; /** The image can either be tyhe back face or front face of the card. **/ SDL_Rect dstrect ; dstrect.x = current_card->x ; dstrect.y = current_card->y ; dstrect.h = CARD_HEIGHT ; if ((*counter) < 73 ) { /** First phase of the animation: the card (back face) width decrease. **/ dstrect.w= 73 - (*counter) ; image_to_display=back_face_texture ; } else if (((*counter) >= 73) && ((*counter) < 73*2)) { /** Second phase of the animation: the card (front face) width increase. **/ dstrect.w= (int) fabs(73 - (*counter)) ; image_to_display=current_card->card_image ; } else if ((*counter) >= 73*2) { /** The animation is finish. * So we reset: * -) the mainloop pausing time, * -) the cursor to the normal arrow. * and the game status is set on playing an animation. ******************************************************/ *sleep=10000 ; game_control->cursor_type = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW) ; SDL_SetCursor(game_control->cursor_type) ; game_control->is_animation_running = false ; game_control->GAME_STATUS=CARDS_DISCOVER ; current_card->is_moving=false ; current_card->is_back_faced=false ; current_card=NULL ; *counter=0 ; if (game_done(game_control->player,game_control->computer)) { #ifdef DEBUG fprintf(stdout,"Switch to ROUND_DONE GAME_STATUS\n") ; #endif buttons[3].is_allowed = false ; buttons[4].is_allowed = true ; game_control->GAME_STATUS = ROUND_DONE ; } return ; } SDL_RenderCopyEx(pRenderer, image_to_display, NULL, &dstrect, 0, NULL, SDL_FLIP_NONE) ; return ; }
int RunAllTests(int argc, char *argv[]) { int flags = log_flags; log_flags = LOG_FLUSH | LOG_CPERROR; /* self-test */ ADD_SUITE(tests); ADD_SUITE(callback); ADD_SUITE(seen); ADD_SUITE(json); ADD_SUITE(jsonconf); ADD_SUITE(direction); ADD_SUITE(skill); ADD_SUITE(keyword); ADD_SUITE(order); ADD_SUITE(race); /* util */ ADD_SUITE(config); ADD_SUITE(attrib); ADD_SUITE(base36); ADD_SUITE(bsdstring); ADD_SUITE(functions); ADD_SUITE(parser); ADD_SUITE(password); ADD_SUITE(umlaut); ADD_SUITE(unicode); ADD_SUITE(strings); ADD_SUITE(rng); /* items */ ADD_SUITE(xerewards); /* kernel */ ADD_SUITE(alliance); ADD_SUITE(unit); ADD_SUITE(faction); ADD_SUITE(group); ADD_SUITE(build); ADD_SUITE(pool); ADD_SUITE(curse); ADD_SUITE(equipment); ADD_SUITE(item); ADD_SUITE(magic); ADD_SUITE(alchemy); ADD_SUITE(reports); ADD_SUITE(save); ADD_SUITE(ship); ADD_SUITE(spellbook); ADD_SUITE(building); ADD_SUITE(spell); ADD_SUITE(spells); ADD_SUITE(magicresistance); ADD_SUITE(ally); ADD_SUITE(messages); /* gamecode */ ADD_SUITE(prefix); ADD_SUITE(battle); ADD_SUITE(donations); ADD_SUITE(travelthru); ADD_SUITE(economy); ADD_SUITE(flyingship); ADD_SUITE(give); ADD_SUITE(laws); ADD_SUITE(market); ADD_SUITE(monsters); ADD_SUITE(move); ADD_SUITE(piracy); ADD_SUITE(stealth); ADD_SUITE(otherfaction); ADD_SUITE(upkeep); ADD_SUITE(vortex); ADD_SUITE(wormhole); ADD_SUITE(spy); ADD_SUITE(study); ADD_SUITE(shock); if (suites) { CuSuite *summary = CuSuiteNew(); int fail_count; game_init(); while (suites) { suite *s = suites->next; RunTests(suites->csuite, suites->name); summary->failCount += suites->csuite->failCount; summary->count += suites->csuite->count; CuSuiteDelete(suites->csuite); free(suites->name); free(suites); suites = s; } printf("\ntest summary: %d tests, %d failed\n", summary->count, summary->failCount); log_flags = flags; fail_count = summary->failCount; CuSuiteDelete(summary); game_done(); return fail_count; } return 0; }