mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
removed some old code
This commit is contained in:
parent
ea245b969d
commit
4c987519b0
|
@ -1,110 +0,0 @@
|
||||||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
|
||||||
/*
|
|
||||||
#include <engine/e_interface.h>
|
|
||||||
#include <engine/e_config.h>
|
|
||||||
#include "gc_mapres_tilemap.h"
|
|
||||||
#include "gc_mapres_image.h"
|
|
||||||
#include "../g_mapres.h"
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
TILEFLAG_VFLIP=1,
|
|
||||||
TILEFLAG_HFLIP=2,
|
|
||||||
};
|
|
||||||
|
|
||||||
int tilemap_init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tilemap_render(float scale, int fg)
|
|
||||||
{
|
|
||||||
if(!map_is_loaded())
|
|
||||||
return;
|
|
||||||
|
|
||||||
float screen_x0, screen_y0, screen_x1, screen_y1;
|
|
||||||
gfx_getscreen(&screen_x0, &screen_y0, &screen_x1, &screen_y1);
|
|
||||||
|
|
||||||
// fetch indecies
|
|
||||||
int start, num;
|
|
||||||
map_get_type(MAPRES_TILEMAP, &start, &num);
|
|
||||||
|
|
||||||
// render tilemaps
|
|
||||||
int passed_main = 0;
|
|
||||||
for(int t = 0; t < num; t++)
|
|
||||||
{
|
|
||||||
mapres_tilemap *tmap = (mapres_tilemap *)map_get_item(start+t,0,0);
|
|
||||||
unsigned char *data = (unsigned char *)map_get_data(tmap->data);
|
|
||||||
|
|
||||||
if(tmap->main)
|
|
||||||
passed_main = 1;
|
|
||||||
|
|
||||||
if((fg && passed_main) || (!fg && !passed_main))
|
|
||||||
{
|
|
||||||
if(!config.gfx_high_detail && !tmap->main)
|
|
||||||
continue;
|
|
||||||
gfx_texture_set(img_get(tmap->image));
|
|
||||||
|
|
||||||
gfx_quads_begin();
|
|
||||||
|
|
||||||
int starty = (int)(screen_y0/scale)-1;
|
|
||||||
int startx = (int)(screen_x0/scale)-1;
|
|
||||||
int endy = (int)(screen_y1/scale)+1;
|
|
||||||
int endx = (int)(screen_x1/scale)+1;
|
|
||||||
|
|
||||||
float frac = (1.25f/1024.0f);//2.0f; //2.0f;
|
|
||||||
float texsize = 1024.0f;
|
|
||||||
float nudge = 0.5f/texsize;
|
|
||||||
for(int y = starty; y < endy; y++)
|
|
||||||
for(int x = startx; x < endx; x++)
|
|
||||||
{
|
|
||||||
int mx = x;
|
|
||||||
int my = y;
|
|
||||||
if(mx<0) mx = 0;
|
|
||||||
if(mx>=tmap->width) mx = tmap->width-1;
|
|
||||||
if(my<0) my = 0;
|
|
||||||
if(my>=tmap->height) my = tmap->height-1;
|
|
||||||
|
|
||||||
int c = mx + my*tmap->width;
|
|
||||||
|
|
||||||
unsigned char d = data[c*2];
|
|
||||||
unsigned char f = data[c*2+1];
|
|
||||||
if(d)
|
|
||||||
{
|
|
||||||
int tx = d%16;
|
|
||||||
int ty = d/16;
|
|
||||||
int px0 = tx*(1024/16);
|
|
||||||
int py0 = ty*(1024/16);
|
|
||||||
int px1 = (tx+1)*(1024/16)-1;
|
|
||||||
int py1 = (ty+1)*(1024/16)-1;
|
|
||||||
|
|
||||||
float u0 = nudge + px0/texsize+frac;
|
|
||||||
float v0 = nudge + py0/texsize+frac;
|
|
||||||
float u1 = nudge + px1/texsize-frac;
|
|
||||||
float v1 = nudge + py1/texsize-frac;
|
|
||||||
|
|
||||||
if(f&TILEFLAG_VFLIP)
|
|
||||||
{
|
|
||||||
float tmp = u0;
|
|
||||||
u0 = u1;
|
|
||||||
u1 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(f&TILEFLAG_HFLIP)
|
|
||||||
{
|
|
||||||
float tmp = v0;
|
|
||||||
v0 = v1;
|
|
||||||
v1 = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
gfx_quads_setsubset(u0,v0,u1,v1);
|
|
||||||
|
|
||||||
gfx_quads_drawTL(x*scale, y*scale, scale, scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gfx_quads_end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -1,20 +0,0 @@
|
||||||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
|
||||||
|
|
||||||
// dependencies: image
|
|
||||||
|
|
||||||
//
|
|
||||||
int tilemap_init();
|
|
||||||
|
|
||||||
// renders the tilemaps
|
|
||||||
void tilemap_render(float scale, int fg);
|
|
||||||
|
|
||||||
struct mapres_tilemap
|
|
||||||
{
|
|
||||||
int image;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
int x, y;
|
|
||||||
int scale;
|
|
||||||
int data;
|
|
||||||
int main;
|
|
||||||
};
|
|
|
@ -12,10 +12,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <game/client/gc_map_image.h>
|
#include <game/client/gc_map_image.h>
|
||||||
#include <game/client/gc_mapres_tilemap.h>
|
|
||||||
#include <game/client/gc_ui.h>
|
#include <game/client/gc_ui.h>
|
||||||
//#include "game/mapres_col.h"
|
|
||||||
#include <game/g_mapres.h>
|
|
||||||
#include <game/g_game.h>
|
#include <game/g_game.h>
|
||||||
#include <game/client/gc_render.h>
|
#include <game/client/gc_render.h>
|
||||||
|
|
||||||
|
@ -26,7 +23,7 @@ static int background_texture = 0;
|
||||||
static int cursor_texture = 0;
|
static int cursor_texture = 0;
|
||||||
static int entities_texture = 0;
|
static int entities_texture = 0;
|
||||||
|
|
||||||
|
// backwards compatiblity
|
||||||
class mapres_image
|
class mapres_image
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -36,6 +33,27 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct mapres_tilemap
|
||||||
|
{
|
||||||
|
int image;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int x, y;
|
||||||
|
int scale;
|
||||||
|
int data;
|
||||||
|
int main;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MAPRES_REGISTERED=0x8000,
|
||||||
|
MAPRES_IMAGE=0x8001,
|
||||||
|
MAPRES_TILEMAP=0x8002,
|
||||||
|
MAPRES_COLLISIONMAP=0x8003,
|
||||||
|
MAPRES_TEMP_THEME=0x8fff,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EDITOR editor;
|
EDITOR editor;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
MAPRES_REGISTERED=0x8000,
|
|
||||||
MAPRES_IMAGE=0x8001,
|
|
||||||
MAPRES_TILEMAP=0x8002,
|
|
||||||
MAPRES_COLLISIONMAP=0x8003,
|
|
||||||
MAPRES_TEMP_THEME=0x8fff,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mapres_theme
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
};
|
|
|
@ -141,6 +141,8 @@ public:
|
||||||
|
|
||||||
bool is_friendly_fire(int cid1, int cid2);
|
bool is_friendly_fire(int cid1, int cid2);
|
||||||
|
|
||||||
|
virtual bool on_entity(int index, vec2 pos);
|
||||||
|
|
||||||
virtual void post_reset();
|
virtual void post_reset();
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
||||||
#include <engine/e_config.h>
|
|
||||||
#include "gs_common.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <engine/e_config.h>
|
||||||
|
#include <game/g_mapitems.h>
|
||||||
|
#include "gs_common.h"
|
||||||
|
|
||||||
gameobject::gameobject()
|
gameobject::gameobject()
|
||||||
: entity(OBJTYPE_GAME)
|
: entity(OBJTYPE_GAME)
|
||||||
|
@ -34,6 +35,51 @@ gameobject::gameobject()
|
||||||
teamscore[1] = 0;
|
teamscore[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UGLY!!!!
|
||||||
|
extern vec2 spawn_points[3][64];
|
||||||
|
extern int num_spawn_points[3];
|
||||||
|
|
||||||
|
bool gameobject::on_entity(int index, vec2 pos)
|
||||||
|
{
|
||||||
|
int type = -1;
|
||||||
|
int subtype = 0;
|
||||||
|
|
||||||
|
if(index == ENTITY_SPAWN)
|
||||||
|
spawn_points[0][num_spawn_points[0]++] = pos;
|
||||||
|
else if(index == ENTITY_SPAWN_RED)
|
||||||
|
spawn_points[1][num_spawn_points[1]++] = pos;
|
||||||
|
else if(index == ENTITY_SPAWN_BLUE)
|
||||||
|
spawn_points[2][num_spawn_points[2]++] = pos;
|
||||||
|
else if(index == ENTITY_ARMOR_1)
|
||||||
|
type = POWERUP_ARMOR;
|
||||||
|
else if(index == ENTITY_HEALTH_1)
|
||||||
|
type = POWERUP_HEALTH;
|
||||||
|
else if(index == ENTITY_WEAPON_SHOTGUN)
|
||||||
|
{
|
||||||
|
type = POWERUP_WEAPON;
|
||||||
|
subtype = WEAPON_SHOTGUN;
|
||||||
|
}
|
||||||
|
else if(index == ENTITY_WEAPON_ROCKET)
|
||||||
|
{
|
||||||
|
type = POWERUP_WEAPON;
|
||||||
|
subtype = WEAPON_ROCKET;
|
||||||
|
}
|
||||||
|
else if(index == ENTITY_POWERUP_NINJA)
|
||||||
|
{
|
||||||
|
type = POWERUP_NINJA;
|
||||||
|
subtype = WEAPON_NINJA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type != -1)
|
||||||
|
{
|
||||||
|
powerup *ppower = new powerup(type, subtype);
|
||||||
|
ppower->pos = pos;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void gameobject::endround()
|
void gameobject::endround()
|
||||||
{
|
{
|
||||||
if(warmup) // game can't end when we are running warmup
|
if(warmup) // game can't end when we are running warmup
|
||||||
|
|
|
@ -1,32 +1,31 @@
|
||||||
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
||||||
|
#include <game/g_mapitems.h>
|
||||||
#include "gs_common.h"
|
#include "gs_common.h"
|
||||||
#include "gs_game_ctf.h"
|
#include "gs_game_ctf.h"
|
||||||
|
|
||||||
gameobject_ctf::gameobject_ctf()
|
gameobject_ctf::gameobject_ctf()
|
||||||
{
|
{
|
||||||
// fetch flagstands
|
|
||||||
for(int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
mapres_flagstand *stand;
|
|
||||||
stand = (mapres_flagstand *)map_find_item(MAPRES_FLAGSTAND_RED+i, 0);
|
|
||||||
if(stand)
|
|
||||||
{
|
|
||||||
flag *f = new flag(i);
|
|
||||||
f->stand_pos = vec2(stand->x, stand->y);
|
|
||||||
f->pos = f->stand_pos;
|
|
||||||
flags[i] = f;
|
|
||||||
//dbg_msg("game", "flag at %f,%f", f->pos.x, f->pos.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// report massive failure
|
|
||||||
flags[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
is_teamplay = true;
|
is_teamplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gameobject_ctf::on_entity(int index, vec2 pos)
|
||||||
|
{
|
||||||
|
if(gameobject::on_entity(index, pos))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int team = -1;
|
||||||
|
if(index == ENTITY_FLAGSTAND_RED) team = 0;
|
||||||
|
if(index == ENTITY_FLAGSTAND_BLUE) team = 1;
|
||||||
|
if(team == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
flag *f = new flag(team);
|
||||||
|
f->stand_pos = pos;
|
||||||
|
f->pos = pos;
|
||||||
|
flags[team] = f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void gameobject_ctf::on_player_spawn(class player *p)
|
void gameobject_ctf::on_player_spawn(class player *p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ public:
|
||||||
gameobject_ctf();
|
gameobject_ctf();
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
|
virtual bool on_entity(int index, vec2 pos);
|
||||||
|
|
||||||
virtual void on_player_spawn(class player *p);
|
virtual void on_player_spawn(class player *p);
|
||||||
virtual int on_player_death(class player *victim, class player *killer, int weapon);
|
virtual int on_player_death(class player *victim, class player *killer, int weapon);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2081,41 +2081,8 @@ void mods_init()
|
||||||
for(int x = 0; x < tmap->width; x++)
|
for(int x = 0; x < tmap->width; x++)
|
||||||
{
|
{
|
||||||
int index = tiles[y*tmap->width+x].index - ENTITY_OFFSET;
|
int index = tiles[y*tmap->width+x].index - ENTITY_OFFSET;
|
||||||
int type = -1;
|
|
||||||
int subtype = 0;
|
|
||||||
vec2 pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
vec2 pos(x*32.0f+16.0f, y*32.0f+16.0f);
|
||||||
|
gameobj->on_entity(index, pos);
|
||||||
if(index == ENTITY_SPAWN)
|
|
||||||
spawn_points[0][num_spawn_points[0]++] = pos;
|
|
||||||
else if(index == ENTITY_SPAWN_RED)
|
|
||||||
spawn_points[1][num_spawn_points[1]++] = pos;
|
|
||||||
else if(index == ENTITY_SPAWN_BLUE)
|
|
||||||
spawn_points[2][num_spawn_points[2]++] = pos;
|
|
||||||
else if(index == ENTITY_ARMOR_1)
|
|
||||||
type = POWERUP_ARMOR;
|
|
||||||
else if(index == ENTITY_HEALTH_1)
|
|
||||||
type = POWERUP_HEALTH;
|
|
||||||
else if(index == ENTITY_WEAPON_SHOTGUN)
|
|
||||||
{
|
|
||||||
type = POWERUP_WEAPON;
|
|
||||||
subtype = WEAPON_SHOTGUN;
|
|
||||||
}
|
|
||||||
else if(index == ENTITY_WEAPON_ROCKET)
|
|
||||||
{
|
|
||||||
type = POWERUP_WEAPON;
|
|
||||||
subtype = WEAPON_ROCKET;
|
|
||||||
}
|
|
||||||
else if(index == ENTITY_POWERUP_NINJA)
|
|
||||||
{
|
|
||||||
type = POWERUP_NINJA;
|
|
||||||
subtype = WEAPON_NINJA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(type != -1)
|
|
||||||
{
|
|
||||||
powerup *ppower = new powerup(type, subtype);
|
|
||||||
ppower->pos = pos;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue