From ea245b969d1864441b41d25c7631beccfb39d874 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 13 Jan 2008 11:15:32 +0000 Subject: new mapformat in place. continued the cleanup. some effects are gone, gonna be redone so no biggie. CTF isn't working now. --- src/game/client/gc_client.cpp | 181 ++++------------------------------ src/game/client/gc_client.h | 1 + src/game/client/gc_hooks.cpp | 11 ++- src/game/client/gc_map_image.cpp | 124 +++++++++++++++++++++++ src/game/client/gc_map_image.h | 10 ++ src/game/client/gc_mapres_image.cpp | 125 ----------------------- src/game/client/gc_mapres_image.h | 19 ---- src/game/client/gc_mapres_tilemap.cpp | 9 +- src/game/client/gc_menu.cpp | 3 - src/game/client/gc_render.cpp | 149 +++++++++++++++++++++++++++- src/game/client/gc_render.h | 4 +- src/game/client/gc_render_map.cpp | 33 +++++-- 12 files changed, 335 insertions(+), 334 deletions(-) create mode 100644 src/game/client/gc_map_image.cpp create mode 100644 src/game/client/gc_map_image.h delete mode 100644 src/game/client/gc_mapres_image.cpp delete mode 100644 src/game/client/gc_mapres_image.h (limited to 'src/game/client') diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 556fabee..d3e3009a 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -12,7 +12,8 @@ extern "C" { #include "../g_game.h" #include "../g_version.h" #include "../g_mapres.h" -#include "gc_mapres_image.h" +#include "../g_layers.h" +#include "gc_map_image.h" #include "gc_mapres_tilemap.h" #include "../generated/gc_data.h" #include "gc_menu.h" @@ -166,7 +167,17 @@ public: }; -static damage_indicators damageind; +static damage_indicators dmgind; + +void effect_damage_indicator(vec2 pos, vec2 dir) +{ + dmgind.create(pos, dir); +} + +void render_damage_indicators() +{ + dmgind.render(); +} class particle_system { @@ -404,7 +415,7 @@ void process_events(int snaptype) if(item.type == EVENT_DAMAGEINDICATION) { ev_damageind *ev = (ev_damageind *)data; - damageind.create(vec2(ev->x, ev->y), get_direction(ev->angle)); + effect_damage_indicator(vec2(ev->x, ev->y), get_direction(ev->angle)); } else if(item.type == EVENT_AIR_JUMP) { @@ -1106,163 +1117,6 @@ void render_scoreboard(float x, float y, float w, int team, const char *title) } } -void mapscreen_to_world(float center_x, float center_y, float zoom) -{ - //const float default_zoom = 1.5f; - float width = 300*3*zoom*gfx_screenaspect(); - float height = 300*3*zoom; - gfx_mapscreen(center_x-width/2, center_y-height/2, center_x+width/2, center_y+height/2); -} - -// renders the complete game world -void render_world(float center_x, float center_y, float zoom) -{ - mapscreen_to_world(center_x, center_y, zoom); - //gfx_mapscreen(center_x-width/2, center_y-height/2, center_x+width/2, center_y+height/2); - - // render background environment - int theme_id = 0; - mapres_theme *t = (mapres_theme *)map_find_item(MAPRES_TEMP_THEME, 0); - if(t) - theme_id = t->id; - - if(config.gfx_high_detail) - { - if(theme_id == 1) - { - // Winter night - gfx_mapscreen(0,0,1,1); - gfx_texture_set(-1); - gfx_quads_begin(); - vec4 top(0x11/(float)0xff, 0x1a/(float)0xff, 0x21/(float)0xff, 1.0f); - vec4 bottom(0x2a/(float)0xff, 0x40/(float)0xff, 0x52/(float)0xff, 1.0f); - gfx_setcolorvertex(0, top.r, top.g, top.b, top.a); - gfx_setcolorvertex(1, top.r, top.g, top.b, top.a); - gfx_setcolorvertex(2, bottom.r, bottom.g, bottom.b, bottom.a); - gfx_setcolorvertex(3, bottom.r, bottom.g, bottom.b, bottom.a); - gfx_quads_drawTL(0, 0, 1, 1); - gfx_quads_end(); - - mapscreen_to_world(center_x*0.1f, center_y*0.1f, zoom); - render_stars(); - - mapscreen_to_world(center_x, center_y, zoom); - - render_moon(center_x*0.8f, center_y*0.8f); - - mapscreen_to_world(center_x, center_y, zoom); - } - else - { - // Summer day - render_sun(20+center_x*0.6f, 20+center_y*0.6f); - - // draw clouds - static vec2 cloud_pos[6] = {vec2(-500,0),vec2(-500,200),vec2(-500,400)}; - static float cloud_speed[6] = {30, 20, 10}; - static int cloud_sprites[6] = {SPRITE_CLOUD1, SPRITE_CLOUD2, SPRITE_CLOUD3}; - - gfx_texture_set(data->images[IMAGE_CLOUDS].id); - gfx_quads_begin(); - for(int i = 0; i < 3; i++) - { - float parallax_amount = 0.55f; - select_sprite(cloud_sprites[i]); - draw_sprite((cloud_pos[i].x+fmod(client_localtime()*cloud_speed[i]+i*100.0f, 3000.0f))+center_x*parallax_amount, - cloud_pos[i].y+center_y*parallax_amount, 300); - } - gfx_quads_end(); - - // draw backdrop - gfx_texture_set(data->images[IMAGE_BACKDROP].id); - gfx_quads_begin(); - float parallax_amount = 0.25f; - for(int x = -1; x < 3; x++) - gfx_quads_drawTL(1024*x+center_x*parallax_amount, (center_y)*parallax_amount+150+512, 1024, 512); - gfx_quads_end(); - } - } - - // render background tilemaps - tilemap_render(32.0f, 0); - - // render items - { - int num = snap_num_items(SNAP_CURRENT); - for(int i = 0; i < num; i++) - { - SNAP_ITEM item; - const void *data = snap_get_item(SNAP_CURRENT, i, &item); - - if(item.type == OBJTYPE_PROJECTILE) - { - //const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); - //if(prev) - render_projectile((const obj_projectile *)data, item.id); - } - else if(item.type == OBJTYPE_POWERUP) - { - const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); - if(prev) - render_powerup((const obj_powerup *)prev, (const obj_powerup *)data); - } - else if(item.type == OBJTYPE_FLAG) - { - const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); - if (prev) - render_flag((const obj_flag *)prev, (const obj_flag *)data); - } - } - } - - // render players above all - { - int num = snap_num_items(SNAP_CURRENT); - for(int i = 0; i < num; i++) - { - SNAP_ITEM item; - const void *data = snap_get_item(SNAP_CURRENT, i, &item); - - if(item.type == OBJTYPE_PLAYER_CHARACTER) - { - const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); - const void *prev_info = snap_find_item(SNAP_PREV, OBJTYPE_PLAYER_INFO, item.id); - const void *info = snap_find_item(SNAP_CURRENT, OBJTYPE_PLAYER_INFO, item.id); - - if(prev && prev_info && info) - { - render_player( - (const obj_player_character *)prev, - (const obj_player_character *)data, - (const obj_player_info *)prev_info, - (const obj_player_info *)info - ); - } - } - } - } - - // render particles - temp_system.update(client_frametime()); - temp_system.render(); - - // render foreground tilemaps - tilemap_render(32.0f, 1); - - // render front environment effects - if(config.gfx_high_detail) - { - if(theme_id == 1) - { - //mapscreen_to_world(center_x, center_y, zoom); - render_snow(); - } - } - - // render damage indications - damageind.render(); -} - static int do_input(int *v, int key) { *v += inp_key_presses(key) + inp_key_releases(key); @@ -1534,6 +1388,7 @@ void render_game() // pseudo format // ZOOM ZOOM + /* float zoom = 3.0; // DEBUG TESTING @@ -1625,7 +1480,7 @@ void render_game() p1f.x,p1f.y); gfx_quads_end(); - } + }*/ if(local_character && !spectate && !(gameobj && gameobj->game_over)) { @@ -1993,8 +1848,8 @@ void render_game() vec2(local_character->x, local_character->y)); char buf[512]; - sprintf(buf, "%f", speed); - gfx_text(0, 150, 50, 24, buf, -1); + sprintf(buf, "%.2f", speed); + gfx_text(0, 150, 50, 12, buf, -1); } // render score board diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h index d34ccc78..f1ff02b1 100644 --- a/src/game/client/gc_client.h +++ b/src/game/client/gc_client.h @@ -91,3 +91,4 @@ void reset_projectile_particles(); void send_info(bool start); void effect_air_jump(vec2 pos); +void effect_damage_indicator(vec2 pos, vec2 dir); diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index febb6478..d0754c09 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -11,10 +11,12 @@ extern "C" { #include #include +#include + #include "gc_client.h" #include "gc_skin.h" #include "gc_render.h" -#include "gc_mapres_image.h" +#include "gc_map_image.h" #include "gc_mapres_tilemap.h" extern unsigned char internal_data[]; @@ -472,10 +474,11 @@ extern "C" void modc_message(int msg) extern "C" void modc_connected() { // init some stuff - col_init(32); - + layers_init(); + col_init(); img_init(); - tilemap_init(); + + //tilemap_init(); chat_reset(); reset_projectile_particles(); diff --git a/src/game/client/gc_map_image.cpp b/src/game/client/gc_map_image.cpp new file mode 100644 index 00000000..ab4d9aa7 --- /dev/null +++ b/src/game/client/gc_map_image.cpp @@ -0,0 +1,124 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include +#include +#include +#include "gc_map_image.h" + +static int map_textures[64] = {0}; +static int count = 0; +/* +static void calc_mipmaps(void *data_in, unsigned width, unsigned height, void *data_out) +{ + unsigned char *src = (unsigned char*)data_in; + unsigned char *dst = (unsigned char*)data_out; + unsigned mip_w = width; + unsigned mip_h = height; + unsigned prev_w; + unsigned prev_h; + + // Highest level - no mod + for(unsigned x = 0; x < mip_w; x++) + { + for(unsigned y = 0; y < mip_h; y++) + { + unsigned i = (y * mip_w + x)<<2; + for(unsigned j = 0; j < 4; j++) + dst[i+j] = src[i+j]; + } + } + + src = dst; + dst += mip_w * mip_h * 4; + prev_w = mip_w; + prev_h = mip_h; + mip_w = mip_w>>1; + mip_h = mip_h>>1; + + while(mip_w > 0 && mip_h > 0) + { + for(unsigned x = 0; x < mip_w; x++) + { + for(unsigned y = 0; y < mip_h; y++) + { + unsigned i = (y * mip_w + x)<<2; + + unsigned r = 0; + unsigned g = 0; + unsigned b = 0; + unsigned a = 0; + + + r += src[(((y<<1) * prev_w + (x<<1))<<2)]; + g += src[(((y<<1) * prev_w + (x<<1))<<2)+1]; + b += src[(((y<<1) * prev_w + (x<<1))<<2)+2]; + a += src[(((y<<1) * prev_w + (x<<1))<<2)+3]; + + r += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)]; + g += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+1]; + b += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+2]; + a += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+3]; + + r += src[((((y+1)<<1) * prev_w + (x<<1))<<2)]; + g += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+1]; + b += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+2]; + a += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+3]; + + r += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)]; + g += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+1]; + b += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+2]; + a += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+3]; + + dst[i] = r>>2; + dst[i+1] = g>>2; + dst[i+2] = b>>2; + dst[i+3] = a>>2; + } + } + + src = dst; + dst = dst + mip_w*mip_h*4; + prev_w = mip_w; + prev_h = mip_h; + mip_w = mip_w>>1; + mip_h = mip_h>>1; + } +} +extern int DEBUGTEST_MAPIMAGE; +*/ + + +int img_init() +{ + int start, count; + map_get_type(MAPITEMTYPE_IMAGE, &start, &count); + dbg_msg("image", "start=%d count=%d", start, count); + for(int i = 0; i < 64; i++) + { + if(map_textures[i]) + { + gfx_unload_texture(map_textures[i]); + map_textures[i] = 0; + } + } + + //void *data_res = (void*)mem_alloc(1024*1024*4*2, 16); + for(int i = 0; i < count; i++) + { + MAPITEM_IMAGE *img = (MAPITEM_IMAGE *)map_get_item(start+i, 0, 0); + void *data = map_get_data(img->image_data); + map_textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data, IMG_RGBA); + map_unload_data(img->image_data); + } + + return count; +} + +int img_num() +{ + return count; +} + +int img_get(int index) +{ + return map_textures[index]; +} diff --git a/src/game/client/gc_map_image.h b/src/game/client/gc_map_image.h new file mode 100644 index 00000000..d73f43d3 --- /dev/null +++ b/src/game/client/gc_map_image.h @@ -0,0 +1,10 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ + +// loads images from the map to textures +int img_init(); + +// returns the number of images in the map +int img_num(); + +// fetches the texture id for the image +int img_get(int index); diff --git a/src/game/client/gc_mapres_image.cpp b/src/game/client/gc_mapres_image.cpp deleted file mode 100644 index d8de8a1e..00000000 --- a/src/game/client/gc_mapres_image.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include -#include -#include "gc_mapres_image.h" -#include "../g_mapres.h" - -static int map_textures[64] = {0}; -static int count = 0; -/* -static void calc_mipmaps(void *data_in, unsigned width, unsigned height, void *data_out) -{ - unsigned char *src = (unsigned char*)data_in; - unsigned char *dst = (unsigned char*)data_out; - unsigned mip_w = width; - unsigned mip_h = height; - unsigned prev_w; - unsigned prev_h; - - // Highest level - no mod - for(unsigned x = 0; x < mip_w; x++) - { - for(unsigned y = 0; y < mip_h; y++) - { - unsigned i = (y * mip_w + x)<<2; - for(unsigned j = 0; j < 4; j++) - dst[i+j] = src[i+j]; - } - } - - src = dst; - dst += mip_w * mip_h * 4; - prev_w = mip_w; - prev_h = mip_h; - mip_w = mip_w>>1; - mip_h = mip_h>>1; - - while(mip_w > 0 && mip_h > 0) - { - for(unsigned x = 0; x < mip_w; x++) - { - for(unsigned y = 0; y < mip_h; y++) - { - unsigned i = (y * mip_w + x)<<2; - - unsigned r = 0; - unsigned g = 0; - unsigned b = 0; - unsigned a = 0; - - - r += src[(((y<<1) * prev_w + (x<<1))<<2)]; - g += src[(((y<<1) * prev_w + (x<<1))<<2)+1]; - b += src[(((y<<1) * prev_w + (x<<1))<<2)+2]; - a += src[(((y<<1) * prev_w + (x<<1))<<2)+3]; - - r += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)]; - g += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+1]; - b += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+2]; - a += src[(((y<<1) * prev_w + ((x+1)<<1))<<2)+3]; - - r += src[((((y+1)<<1) * prev_w + (x<<1))<<2)]; - g += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+1]; - b += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+2]; - a += src[((((y+1)<<1) * prev_w + (x<<1))<<2)+3]; - - r += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)]; - g += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+1]; - b += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+2]; - a += src[((((y+1)<<1) * prev_w + ((x+1)<<1))<<2)+3]; - - dst[i] = r>>2; - dst[i+1] = g>>2; - dst[i+2] = b>>2; - dst[i+3] = a>>2; - } - } - - src = dst; - dst = dst + mip_w*mip_h*4; - prev_w = mip_w; - prev_h = mip_h; - mip_w = mip_w>>1; - mip_h = mip_h>>1; - } -} -*/ -extern int DEBUGTEST_MAPIMAGE; - -int img_init() -{ - int start, count; - map_get_type(MAPRES_IMAGE, &start, &count); - dbg_msg("mapres_image", "start=%d count=%d", start, count); - for(int i = 0; i < 64; i++) - { - if(map_textures[i]) - { - gfx_unload_texture(map_textures[i]); - map_textures[i] = 0; - } - } - - //void *data_res = (void*)mem_alloc(1024*1024*4*2, 16); - for(int i = 0; i < count; i++) - { - mapres_image *img = (mapres_image *)map_get_item(start+i, 0, 0); - void *data = map_get_data(img->image_data); - //calc_mipmaps(data, img->width, img->height, data_res); - map_textures[i] = gfx_load_texture_raw(img->width, img->height, IMG_RGBA, data, IMG_RGBA); - map_unload_data(img->image_data); - } - - //mem_free(data_res); - return count; -} - -int img_num() -{ - return count; -} - -int img_get(int index) -{ - return map_textures[index]; -} diff --git a/src/game/client/gc_mapres_image.h b/src/game/client/gc_mapres_image.h deleted file mode 100644 index f841ca53..00000000 --- a/src/game/client/gc_mapres_image.h +++ /dev/null @@ -1,19 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ - -// loads images from the map to textures -int img_init(); - -// returns the number of images in the map -int img_num(); - -// fetches the texture id for the image -int img_get(int index); - - -class mapres_image -{ -public: - int width; - int height; - int image_data; -}; diff --git a/src/game/client/gc_mapres_tilemap.cpp b/src/game/client/gc_mapres_tilemap.cpp index 99976b64..239d2d92 100644 --- a/src/game/client/gc_mapres_tilemap.cpp +++ b/src/game/client/gc_mapres_tilemap.cpp @@ -1,4 +1,5 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +/* #include #include #include "gc_mapres_tilemap.h" @@ -15,13 +16,6 @@ int tilemap_init() { return 0; } -/* -struct render_info -{ - unsigned char *data; -}; - -void tilemap_render_one()*/ void tilemap_render(float scale, int fg) { @@ -113,3 +107,4 @@ void tilemap_render(float scale, int fg) } } } +*/ diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index e0c2a19f..cc9eaaea 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -18,9 +18,6 @@ extern "C" { #include "../g_version.h" #include "../g_protocol.h" -#include "gc_mapres_image.h" -#include "gc_mapres_tilemap.h" - #include "../generated/gc_data.h" #include "gc_render.h" #include "gc_anim.h" diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp index 9a4c35d5..9f55ec5f 100644 --- a/src/game/client/gc_render.cpp +++ b/src/game/client/gc_render.cpp @@ -2,12 +2,14 @@ #include #include #include -#include "../generated/gc_data.h" -#include "../g_protocol.h" -#include "../g_math.h" +#include +#include +#include +#include #include "gc_render.h" #include "gc_anim.h" #include "gc_client.h" +#include "gc_map_image.h" static float sprite_w_scale; static float sprite_h_scale; @@ -235,3 +237,144 @@ void mapscreen_to_world(float center_x, float center_y, float parallax_x, float points[2] = offset_x+center_x+width/2; points[3] = offset_y+center_y+height/2; } + +static void mapscreen_to_group(float center_x, float center_y, MAPITEM_GROUP *group) +{ + float points[4]; + mapscreen_to_world(center_x, center_y, group->parallax_x/100.0f, group->parallax_y/100.0f, + group->offset_x, group->offset_y, gfx_screenaspect(), 1.0f, points); + gfx_mapscreen(points[0], points[1], points[2], points[3]); +} + +void render_layers(float center_x, float center_y, int pass) +{ + bool passed_gamelayer = false; + for(int g = 0; g < layers_num_groups(); g++) + { + MAPITEM_GROUP *group = layers_get_group(g); + + mapscreen_to_group(center_x, center_y, group); + + for(int l = 0; l < group->num_layers; l++) + { + MAPITEM_LAYER *layer = layers_get_layer(group->start_layer+l); + bool render = false; + bool is_game_layer = false; + + if(layer == (MAPITEM_LAYER*)layers_game()) + { + is_game_layer = true; + passed_gamelayer = 1; + } + + if(pass == 0) + { + if(passed_gamelayer) + return; + render = true; + } + else + { + if(passed_gamelayer && !is_game_layer) + render = true; + } + + if(render) + { + if(layer->type == LAYERTYPE_TILES) + { + MAPITEM_LAYER_TILEMAP *tmap = (MAPITEM_LAYER_TILEMAP *)layer; + if(tmap->image == -1) + gfx_texture_set(-1); + else + gfx_texture_set(img_get(tmap->image)); + TILE *tiles = (TILE *)map_get_data(tmap->data); + render_tilemap(tiles, tmap->width, tmap->height, 32.0f, 1); + } + else if(layer->type == LAYERTYPE_QUADS) + { + MAPITEM_LAYER_QUADS *qlayer = (MAPITEM_LAYER_QUADS *)layer; + if(qlayer->image == -1) + gfx_texture_set(-1); + else + gfx_texture_set(img_get(qlayer->image)); + QUAD *quads = (QUAD *)map_get_data_swapped(qlayer->data); + render_quads(quads, qlayer->num_quads); + } + } + } + } +} + +// renders the complete game world +void render_world(float center_x, float center_y, float zoom) +{ + // render background layers + render_layers(center_x, center_y, 0); + + // render items + { + int num = snap_num_items(SNAP_CURRENT); + for(int i = 0; i < num; i++) + { + SNAP_ITEM item; + const void *data = snap_get_item(SNAP_CURRENT, i, &item); + + if(item.type == OBJTYPE_PROJECTILE) + { + //const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); + //if(prev) + render_projectile((const obj_projectile *)data, item.id); + } + else if(item.type == OBJTYPE_POWERUP) + { + const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); + if(prev) + render_powerup((const obj_powerup *)prev, (const obj_powerup *)data); + } + else if(item.type == OBJTYPE_FLAG) + { + const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); + if (prev) + render_flag((const obj_flag *)prev, (const obj_flag *)data); + } + } + } + + // render players above all + { + int num = snap_num_items(SNAP_CURRENT); + for(int i = 0; i < num; i++) + { + SNAP_ITEM item; + const void *data = snap_get_item(SNAP_CURRENT, i, &item); + + if(item.type == OBJTYPE_PLAYER_CHARACTER) + { + const void *prev = snap_find_item(SNAP_PREV, item.type, item.id); + const void *prev_info = snap_find_item(SNAP_PREV, OBJTYPE_PLAYER_INFO, item.id); + const void *info = snap_find_item(SNAP_CURRENT, OBJTYPE_PLAYER_INFO, item.id); + + if(prev && prev_info && info) + { + render_player( + (const obj_player_character *)prev, + (const obj_player_character *)data, + (const obj_player_info *)prev_info, + (const obj_player_info *)info + ); + } + } + } + } + + // render particles + //temp_system.update(client_frametime()); + //temp_system.render(); + + // render foreground layers + render_layers(center_x, center_y, 1); + + // render damage indications + render_damage_indicators(); +} diff --git a/src/game/client/gc_render.h b/src/game/client/gc_render.h index 2f17f6b5..feb04641 100644 --- a/src/game/client/gc_render.h +++ b/src/game/client/gc_render.h @@ -37,6 +37,8 @@ void render_game(); void render_world(float center_x, float center_y, float zoom); void render_loading(float percent); +void render_damage_indicators(); + // object render methods (gc_render_obj.cpp) void render_tee(class animstate *anim, tee_render_info *info, int emote, vec2 dir, vec2 pos); void render_flag(const struct obj_flag *prev, const struct obj_flag *current); @@ -48,7 +50,7 @@ void render_player( // map render methods (gc_render_map.cpp) void render_quads(QUAD *quads, int num_quads); -void render_tilemap(TILE *tiles, int w, int h, float scale); +void render_tilemap(TILE *tiles, int w, int h, float scale, int flags); // helpers void mapscreen_to_world(float center_x, float center_y, float parallax_x, float parallax_y, diff --git a/src/game/client/gc_render_map.cpp b/src/game/client/gc_render_map.cpp index fcb8c272..4345aa03 100644 --- a/src/game/client/gc_render_map.cpp +++ b/src/game/client/gc_render_map.cpp @@ -88,7 +88,7 @@ void render_quads(QUAD *quads, int num_quads) } -void render_tilemap(TILE *tiles, int w, int h, float scale) +void render_tilemap(TILE *tiles, int w, int h, float scale, int flags) { //gfx_texture_set(img_get(tmap->image)); float screen_x0, screen_y0, screen_x1, screen_y1; @@ -116,14 +116,29 @@ void render_tilemap(TILE *tiles, int w, int h, float scale) { int mx = x; int my = y; - if(mx<0) - continue; // mx = 0; - if(mx>=w) - continue; // mx = w-1; - if(my<0) - continue; // my = 0; - if(my>=h) - continue; // my = h-1; + + if(flags) + { + if(mx<0) + mx = 0; + if(mx>=w) + mx = w-1; + if(my<0) + my = 0; + if(my>=h) + my = h-1; + } + else + { + if(mx<0) + continue; // mx = 0; + if(mx>=w) + continue; // mx = w-1; + if(my<0) + continue; // my = 0; + if(my>=h) + continue; // my = h-1; + } int c = mx + my*w; -- cgit 1.4.1