diff --git a/about.c b/about.c index db58351..a4a95fe 100644 --- a/about.c +++ b/about.c @@ -10,7 +10,7 @@ void start_about(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h )) window->height += font->maxheight*16; window->only_ok = 1; modal_window(window,resize); - delete_window(window); + delete_window(window); } const char help_text[] = @@ -45,7 +45,6 @@ const char help_text[] = spTextBlockPointer help_block; Sint32 help_scroll; -spFontPointer help_font; struct { int x; @@ -189,6 +188,6 @@ void start_help(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h )) help_scroll = 0; help_font = font; spLoop(help_draw,help_calc,10,resize,NULL); - + spDeleteTextBlock(help_block); } diff --git a/client.c b/client.c index 932ff94..0632eca 100644 --- a/client.c +++ b/client.c @@ -8,6 +8,7 @@ spNetIP ip; char hase_url[512] = ""; char hase_gzip = 0; +int last_heartbeat_diff = -1; void addToMessage(pMessage *message, char* name, char* content) { @@ -39,8 +40,6 @@ void deleteMessage(pMessage *message) #define INPUT_COMPRESSION #endif -int last_heartbeat_diff = -1; - pMessage sendMessage(pMessage message,char* binary_name,void* binary,int count,char* dest,char* server) { char boundary[17] = "A9B8C7D6E5F4G3H2"; //This should maybe random... diff --git a/client.h b/client.h index 91b8fc0..42ddf96 100644 --- a/client.h +++ b/client.h @@ -150,6 +150,8 @@ typedef struct sThreadData pThreadData next; } tThreadData; +extern int last_heartbeat_diff; + int server_info(); pGame create_game(char* game_name,Uint32 options,int seconds_per_turn,char* level_string,int local,int hares_per_player); void delete_game_list(pGame game); diff --git a/hase.c b/hase.c index e14b78a..f40d582 100644 --- a/hase.c +++ b/hase.c @@ -25,8 +25,6 @@ spSound* snd_turn; spSound* snd_item; spSound* snd_create; -spFontPointer font; -spFontPointer font_dark; SDL_Surface* level; SDL_Surface* level_original; Uint16* level_pixel; @@ -34,7 +32,7 @@ SDL_Surface* arrow; int posX,posY,rotation; int mapviewX,mapviewY; Sint32 zoom; -Sint32 zoom_d; +Sint32 zoom_d; Sint32 zoomAdjust; Sint32 zoomAdjustAdjust; Sint32 minZoom,maxZoom; @@ -78,10 +76,8 @@ spSpriteCollectionPointer targeting; spNetIRCMessagePointer before_showing; -SDL_Surface* screen; SDL_Surface* tomato; -spFontPointer help_font; struct { int x; @@ -133,7 +129,7 @@ SDL_Surface* map_surface; void draw_map(int px,int py) { - spRotozoomSurface(px,py,0,map_surface,SP_ONE,SP_ONE,rotation); + spRotozoomSurface(px,py,0,map_surface,SP_ONE,SP_ONE,rotation); //player int j; for (j = 0; j < player_count; j++) @@ -143,7 +139,7 @@ void draw_map(int px,int py) pHare hare = player[j]->firstHare; if (hare) do - { + { int X = hare->x-(LEVEL_WIDTH << SP_ACCURACY-1); int Y = hare->y-(LEVEL_HEIGHT << SP_ACCURACY-1); int x = px+(spMul(spCos(rotation),X) - spMul(spSin(rotation),Y) >> SP_ACCURACY)*map_w/LEVEL_WIDTH; @@ -159,7 +155,7 @@ void draw_map(int px,int py) spEllipse(x,y,0,map_size,map_size,spGetFastRGB(255,0,0)); hare = hare->next; } - while (hare != player[j]->firstHare); + while (hare != player[j]->firstHare); } pItem item = firstItem; while (item) @@ -222,7 +218,7 @@ void draw(void) spSetHorizontalOrigin(SP_FIXED); if (gop_rotation() == 0) rotation = 0; - + //Level spRotozoomSurface(screen->w/2,screen->h/2,0,level,zoom,zoom,rotation); @@ -248,10 +244,10 @@ void draw(void) continue; pixels[x+y*screen->w] = texture[a+b*LEVEL_WIDTH]; }*/ - + spSetVerticalOrigin(SP_CENTER); spSetHorizontalOrigin(SP_CENTER); - + //Items items_draw(); @@ -264,7 +260,7 @@ void draw(void) pHare hare = player[j]->firstHare; if (hare) do - { + { spSpritePointer sprite = spActiveSprite(hare->hase); spSetSpriteZoom(sprite,zoom/2,zoom/2); spSetSpriteRotation(sprite,+rotation+hare->cam_rotation); @@ -285,7 +281,7 @@ void draw(void) //building if (w_nr == WP_BUILD_SML || w_nr == WP_BUILD_MID || w_nr == WP_BUILD_BIG) { - + int r = (zoom*weapon_explosion[w_nr] >> SP_ACCURACY+1); int d = 12+weapon_explosion[w_nr]+(hare->w_build_distance*(12+weapon_explosion[w_nr]) >> SP_ACCURACY); Sint32 ox = spMul(hare->x-posX-d*-spMul(spSin(hare->cam_rotation+hare->w_build_direction-SP_PI/2),hare->w_build_distance+SP_ONE*2/3),zoom); @@ -306,7 +302,7 @@ void draw(void) else if (w_nr == WP_TUNNEL_SML || w_nr == WP_TUNNEL_MID || w_nr == WP_TUNNEL_BIG) { - + int r = (zoom*weapon_explosion[w_nr] >> SP_ACCURACY+1); int d = 12+weapon_explosion[w_nr]+(hare->w_build_distance*(12+weapon_explosion[w_nr]) >> SP_ACCURACY); Sint32 ox = spMul(hare->x-posX-d*-spMul(spSin(hare->cam_rotation+hare->w_build_direction-SP_PI/2),hare->w_build_distance+SP_ONE*2/3),zoom); @@ -327,7 +323,7 @@ void draw(void) else if (w_nr == WP_TELEPORT) { - + int r = (zoom*20 >> SP_ACCURACY+1); int d = 12+weapon_explosion[w_nr]+(hare->w_build_distance*(12+weapon_explosion[w_nr]) >> SP_ACCURACY); Sint32 ox = spMul(hare->x-posX-d*-spMul(spSin(hare->cam_rotation+hare->w_build_direction-SP_PI/2),hare->w_build_distance+SP_ONE*2/3),zoom); @@ -383,7 +379,7 @@ void draw(void) spDrawSprite(screen->w/2+nx,screen->h/2+ny,0,target); spLine(screen->w/2+x,screen->h/2+y,0,screen->w/2+nx,screen->h/2+ny,0,get_border_color()); //spSetBlending( SP_ONE ); - } + } } spDrawSprite(screen->w/2+x,screen->h/2+y,0,sprite); //spEllipseBorder(screen->w/2+x,screen->h/2+y,0,PLAYER_RADIUS*zoom >> SP_ACCURACY,PLAYER_RADIUS*zoom >> SP_ACCURACY,1,1,65535); @@ -411,7 +407,7 @@ void draw(void) else pixels[X+Y*screen->w] = spGetFastRGB(255,0,0); }*/ - + //Health bar y-=zoom*3>>14; spSetBlending( SP_ONE*2/3 ); @@ -467,17 +463,17 @@ void draw(void) } //Particles spParticleDraw(particles); - + //Bullets drawBullets(); - + //Trace drawTrace(player[active_player]); - + //Map if (gop_show_map()) draw_map(screen->w-map_w/2,map_h/2); - + //HID int y = 0; if (get_channel()) @@ -495,7 +491,7 @@ void draw(void) line = line->next; } } - + y = screen->h - alive_count * (font->maxheight*3/4+(spGetSizeFactor()*2 >> SP_ACCURACY)); int max_hare_per_player = 0; for (j = 0; j < player_count; j++) @@ -526,7 +522,7 @@ void draw(void) hare = hare->next; } while (hare != player[j]->firstHare); - + int w = health*screen->w/(max_hare_per_player*MAX_HEALTH*5); if (j != active_player) spSetPattern8(153,60,102,195,153,60,102,195); @@ -554,7 +550,7 @@ void draw(void) y += font->maxheight*3/4+(spGetSizeFactor()*2 >> SP_ACCURACY); } - spFontDrawRight( screen->w-1 - player[active_player]->weapon_points * tomato->w, screen->h-1-font->maxheight, 0, + spFontDrawRight( screen->w-1 - player[active_player]->weapon_points * tomato->w, screen->h-1-font->maxheight, 0, player[active_player]->weapon_points > 0 ? "Action points:" : "Action points: None", font ); int i; for (i = 0; i < player[active_player]->weapon_points; i++) @@ -604,12 +600,12 @@ void draw(void) weapon_button[0].w = -1; weapon_button[0].h = -1; } - + if (ragnarok_counter && (hase_game->options.bytewise.ragnarok_border >> 4) < 7) { sprintf(buffer,"RAGNARÖK %i",turn_count - (hase_game->options.bytewise.ragnarok_border >> 4)*5 + 1); spFontDrawMiddle( screen->w >> 1, screen->h*2/3, 0, buffer, font ); - } + } if (player[active_player]->weapon_points) sprintf(buffer,"%is",countdown / 1000); else @@ -621,7 +617,7 @@ void draw(void) sprintf(&buffer[strlen(buffer)]," (>> x%i)",speed); spFontDrawMiddle( screen->w >> 1, screen->h-1-font->maxheight, 0, buffer, font ); - + if (wp_choose) draw_weapons(&(weapon_button[1].x),&(weapon_button[1].y),&(weapon_button[1].w),&(weapon_button[1].h)); @@ -631,7 +627,7 @@ void draw(void) int b_alpha = bullet_alpha(); if (b_alpha) spAddColorToTarget(EXPLOSION_COLOR,b_alpha); - + //Error message if (game_pause) draw_message(); @@ -640,14 +636,14 @@ void draw(void) if (chatWindow) window_draw(); spMapSetMapSet(1); - + #ifdef PROFILE draw_time = SDL_GetTicks() - start_time; sprintf(buffer,"FPS: %i\nDraw: %ims\nCalc: %ims",spGetFPS(),draw_time,calc_time); printf( "FPS: %i\tDraw: %ims\tCalc: %ims\n",spGetFPS(),draw_time,calc_time); spFontDrawMiddle( screen->w >> 1, 1, 0, buffer, font ); #endif - + spFlip(); } @@ -676,7 +672,7 @@ int min_d_not_me(int x,int y,int me, int r) pHare hare = player[i]->firstHare; if (hare) do - { + { int d = spFixedToInt(hare->x-x)*spFixedToInt(hare->x-x)+ spFixedToInt(hare->y-y)*spFixedToInt(hare->y-y); if (i != me) @@ -777,8 +773,6 @@ void get_ms_from_data(int ms) } } -int last_heartbeat_diff; - void set_input() { if (player[active_player]->computer) @@ -803,7 +797,7 @@ void set_input() { input_states[INPUT_AXIS_0_LEFT] = 0; input_states[INPUT_AXIS_0_RIGHT] = 0; - } + } if (gop_direction_flip() && !gop_rotation() && player[active_player]->activeHare->cam_rotation > SP_PI/2 && player[active_player]->activeHare->cam_rotation < SP_PI*3/2) { int temp = input_states[INPUT_AXIS_0_LEFT]; @@ -881,9 +875,9 @@ void set_input() if (last_heartbeat_diff < 90) sprintf(buffer,"Waiting for turn data\nfrom player %s...\n(Last vital sign %i seconds ago, kick at 90)",player[active_player]->name,last_heartbeat_diff); else - sprintf(buffer,"Waiting for turn data\nfrom player %s...",player[active_player]->name); + sprintf(buffer,"Waiting for turn data\nfrom player %s...",player[active_player]->name); set_message(font,buffer); - } + } } if (game_pause == 0) { @@ -933,7 +927,7 @@ int calc(Uint32 steps) sprintf(buffer,"*** %s %s",showing->user,message); else sprintf(buffer,"%s: %s",showing->user,message); - + } else if (gop_global_chat()) @@ -1035,7 +1029,7 @@ int calc(Uint32 steps) spMapSetMapSet(1); spSoundPause(0,-1); } - + if (chatWindow) { spMapSetMapSet(0); @@ -1053,7 +1047,7 @@ int calc(Uint32 steps) } spMapSetMapSet(1); } - + if (spMapGetByID(MAP_CHAT) && get_channel()) { spMapSetByID(MAP_CHAT,0); @@ -1419,7 +1413,7 @@ int calc(Uint32 steps) pHare h = player[k]->firstHare; if (h) do - { + { if (h == player[active_player]->activeHare->circle_checkpoint_hare[j]) { p = player[k]; @@ -1526,7 +1520,7 @@ int calc(Uint32 steps) { if (player[active_player]->activeHare->jump_failed || spRand()%16 == 0) player[active_player]->activeHare->direction = 1-player[active_player]->activeHare->direction; - player[active_player]->activeHare->jump_failed = 0; + player[active_player]->activeHare->jump_failed = 0; switch (spRand()/1337%7) { case 0: case 1: case 2: case 3: @@ -1564,7 +1558,7 @@ int calc(Uint32 steps) } else input_ok_on = 0; - + if (input_states[INPUT_AXIS_0_LEFT]) { if (player[active_player]->activeHare->direction == 1) @@ -1594,7 +1588,7 @@ int calc(Uint32 steps) } else direction_hold = 0; - + if (input_states[INPUT_AXIS_1_LEFT]) { direction_pressed += SP_ONE/20; @@ -1744,7 +1738,7 @@ int calc(Uint32 steps) if (player[active_player]->activeHare->bums && player[active_player]->activeHare->hops <= 0) jump(2); //jump is possible else - player[active_player]->weapon_points+=weapon_cost[w_nr]; //payback + player[active_player]->weapon_points+=weapon_cost[w_nr]; //payback break; case WP_KAIO_KEN: player[active_player]->next_round_extra++; @@ -1790,7 +1784,7 @@ int calc(Uint32 steps) pHare h = player[k]->firstHare; if (h) do - { + { if (h == player[active_player]->activeHare->circle_checkpoint_hare[j]) { p = player[k]; @@ -1846,7 +1840,7 @@ int calc(Uint32 steps) channel_end = -1; } - + if (wp_choose) { if (input_states[INPUT_AXIS_0_LEFT] && player[active_player]->activeHare) @@ -1928,7 +1922,7 @@ int calc(Uint32 steps) p->particle[i].status = -1; else*/ p->particle[i].status = 0; - } + } } #ifdef PROFILE calc_time = SDL_GetTicks() - start_time; @@ -2016,7 +2010,7 @@ int hase(void ( *resize )( Uint16 w, Uint16 h ),pGame game,pPlayer me_list) p->local = 1; p->pw = q->pw; break; - } + } q = q->next; } p = p->next; @@ -2078,11 +2072,11 @@ int hase(void ( *resize )( Uint16 w, Uint16 h ),pGame game,pPlayer me_list) snd_turn = spSoundLoad("./sounds/your_turn.wav"); snd_item = spSoundLoad("./sounds/item.wav"); snd_create = spSoundLoad("./sounds/create.wav"); - + spMapSetMapSet(1); - + start_random_music(); - + if (player[active_player]->local) spSoundPlay(snd_turn,-1,0,0,-1); if ((hase_game->options.bytewise.ragnarok_border >> 4) == 0) @@ -2092,9 +2086,9 @@ int hase(void ( *resize )( Uint16 w, Uint16 h ),pGame game,pPlayer me_list) } int result = spLoop(draw,calc,10,resize,NULL); - + spMapSetMapSet(0); - + spSoundStop(-1,0); spSoundDelete(snd_explosion); spSoundDelete(snd_beep); diff --git a/lobby.c b/lobby.c index abde288..4a26739 100644 --- a/lobby.c +++ b/lobby.c @@ -11,18 +11,12 @@ #include "mapping.h" #include -SDL_Surface* screen; -spFontPointer font = NULL; -spFontPointer font_dark = NULL; - #define BUTTON_FG spGetRGB(32,32,32) #define BUTTON_BG spGetRGB(220,220,220) #define FONT_BG spGetRGB(64,64,64) #define FONT_FG spGetRGB(220,220,220) #define FONT_DARK_FG spGetRGB(110,110,110) -spTextBlockPointer lg_chat_block; - void resize( Uint16 w, Uint16 h ) { #ifdef DESKTOP diff --git a/lobbyGame.c b/lobbyGame.c index d52c114..3d5a373 100644 --- a/lobbyGame.c +++ b/lobbyGame.c @@ -1,6 +1,7 @@ #include "lobbyGame.h" +#include "lobbyList.h" #include "level.h" -#include +#include #include "options.h" #include "client.h" @@ -12,7 +13,6 @@ #define LG_WAIT 5000 spFontPointer lg_font; -spFontPointer font_dark; void ( *lg_resize )( Uint16 w, Uint16 h ); int lg_counter; pGame lg_game; @@ -22,7 +22,6 @@ pPlayer lg_player_list = NULL; pPlayer lg_player; pPlayer lg_last_player; spTextBlockPointer lg_block = NULL; -spTextBlockPointer lg_chat_block = NULL; spNetIRCMessagePointer lg_last_read_message = NULL; Sint32 lg_scroll; char lg_level_string[1024]; @@ -31,7 +30,6 @@ char lg_last_level_string[1024]; SDL_Thread* lg_thread = NULL; int level_mode; -int use_chat; int after_start; tLobbyButton lg_button[ SP_MAPPING_MAX ]; @@ -218,7 +216,7 @@ void lg_draw(void) } else spFontDrawMiddle(screen->w-2-3*w/4, h+7*lg_font->maxheight/2, 0, "Spectate mode!", lg_font ); - + if (lg_game->admin_pw == 0) { if (after_start) @@ -418,7 +416,7 @@ void save_level(char* level_string) SDL_RWclose(file);*/ FILE* file = fopen (complete_path,"w"); fprintf (file, "version 14\n"); - + //Reading the texture... char* mom = level_string; int t = strtol(mom,&mom,36); @@ -1111,8 +1109,8 @@ int lg_calc(Uint32 steps) int l_w = spGetWindowSurface()->h-(1+CHAT_LINES)*lg_font->maxheight; lg_level = create_level(lg_set_level_string,l_w,l_w,LL_BG); } - - + + } return 0; } @@ -1265,19 +1263,19 @@ int game_options_feedback( pWindow window, pWindowElement elem, int action ) case 0: sprintf(elem->text,"Ragnarök: Instant"); break; case 7: sprintf(elem->text,"Ragnarök: No"); break; default: sprintf(elem->text,"Ragnarök after %i rounds",ragnarok*5); - } + } break; case 6: if (border) sprintf(elem->text,"Border behaviour: Infinite"); else - sprintf(elem->text,"Border behaviour: Killing"); + sprintf(elem->text,"Border behaviour: Killing"); break; case 7: if (distant_damage) sprintf(elem->text,"Long shot extra damage: Yes"); else - sprintf(elem->text,"Long shot extra damage: No"); + sprintf(elem->text,"Long shot extra damage: No"); break; case 8: sprintf(elem->text,"AI handicap hares: %i",hdc_count-8); break; case 9: sprintf(elem->text,"AI handicap health: %i",(hdc_health-7)*25); break; @@ -1306,7 +1304,7 @@ int game_options(Uint32 *game_opt,int* game_seconds,int* game_hares,spFontPointe add_window_element(window,0,8); add_window_element(window,0,9); int result = modal_window(window,resize); - delete_window(window); + delete_window(window); *game_opt = lg_game_options; *game_seconds = lg_game_seconds; *game_hares = lg_game_hares; @@ -1364,9 +1362,9 @@ int start_lobby_game(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), lg_chat_text[0] = 0; if (!spectate && !lg_game->local) start_heartbeat(lg_player); - + int res = spLoop(lg_draw,lg_calc,10,resize,NULL); - + if (lg_block) spDeleteTextBlock(lg_block); if (res == -1) @@ -1404,8 +1402,7 @@ int start_lobby_game(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), leave_game(lg_ai_list); lg_ai_list = next; } - + } return result; } - diff --git a/lobbyList.c b/lobbyList.c index 6dff8f0..9da48ea 100644 --- a/lobbyList.c +++ b/lobbyList.c @@ -21,7 +21,12 @@ char ll_game_name[33] = "New game"; spTextBlockPointer ll_chat_block = NULL; Sint32 ll_chat_scroll; -int use_chat; +int use_chat = 0; +spTextBlockPointer lg_chat_block = NULL; +spFontPointer font_dark = NULL; +spFontPointer font = NULL; +spFontPointer help_font = NULL; +SDL_Surface* screen = NULL; pGame mom_game; @@ -41,7 +46,7 @@ void update_ll_surface() spFontDraw( 2+LL_STATUS*ll_surface->w/LL_SURFACE_DIV, pos*ll_font->maxheight-ll_scroll/1024, 0, "Status", ll_font ); pos++; spLine(2,1+pos*ll_font->maxheight-ll_scroll/1024, 0, ll_surface->w-2,1+pos*ll_font->maxheight-ll_scroll/1024, 0, 65535); - + pGame game = ll_game_list; mom_game = NULL; while (game) @@ -106,14 +111,14 @@ void ll_draw(void) sprintf(buffer,"%i Games on Server (Version %i):\n",ll_game_count,CLIENT_VERSION); spFontDrawMiddle( screen->w/3+2, 0*ll_font->maxheight-2, 0, buffer, ll_font ); spBlitSurface(screen->w/3,ll_font->maxheight*1+ll_surface->h/2-1,0,ll_surface); - + spFontDrawMiddle(5*screen->w/6, 0*ll_font->maxheight-2, 0, "Preview & Players", ll_font ); spRectangle(5*screen->w/6, ll_font->maxheight+screen->w/6-5, 0,screen->w/3-6,screen->w/3-6,LL_FG); if (ll_level) spBlitSurface(5*screen->w/6, 1*ll_font->maxheight+screen->w/6-5, 0,ll_level); int h = screen->h-(screen->w/3+3*ll_font->maxheight-6); - + if (use_chat == 0) spFontDrawMiddle(screen->w/2, screen->h-2*ll_font->maxheight-h/2, 0, "Chat deactivated", ll_font); else @@ -146,7 +151,7 @@ void ll_draw(void) } else lobby_draw_buttons( LEFT, 2, screen->h-ll_font->maxheight-button_pos, "{menu}Back", ll_font, ll_button); - + if (ll_reload_now == 1) ll_reload_now = 2; if (ll_reload_now) @@ -241,7 +246,7 @@ int ll_calc(Uint32 steps) spNetIRCMessagePointer next = get_channel()->last_read_message->next; log_message(next->user,next->message); - + if (strcmp(next->ctcp,"ACTION") == 0) sprintf(buffer,"*** %s %s",next->user,next->message); else @@ -298,7 +303,7 @@ int ll_calc(Uint32 steps) } } ll_counter = 10000; - } + } if (spMapGetByID(MAP_JUMP) && ll_reload_now == 0) { spMapSetByID(MAP_JUMP,0); @@ -402,7 +407,7 @@ int ll_calc(Uint32 steps) if (spGetInput()->axis[1] > 0) { if (ll_wait == -1) - { + { ll_wait = MAX_WAIT; ll_selected++; if (ll_level) @@ -489,7 +494,7 @@ int ll_reload(void* dummy) } if (info != CLIENT_VERSION) { - ll_reload_now = 4; + ll_reload_now = 4; return 3; } if (use_chat) @@ -528,7 +533,7 @@ void start_lobby(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ), int strftime(time_buffer,2048,"%c",ti); log_message("Enter lobby",time_buffer); - + ll_selected = 0; ll_font = font; ll_level = NULL; diff --git a/lobbyList.h b/lobbyList.h index fc6be00..a9529de 100644 --- a/lobbyList.h +++ b/lobbyList.h @@ -7,6 +7,13 @@ #define LL_FG spGetRGB(128,128,160) #define LL_BG spGetRGB(64,64,80) +extern int use_chat; +extern spTextBlockPointer lg_chat_block; +extern spFontPointer font_dark; +extern spFontPointer font; +extern spFontPointer help_font; +extern SDL_Surface* screen; + void start_lobby(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ),int start_chat); int ll_reload(void* dummy);