Permalink
Browse files

* Wuestensprite

 * vm id an client uebermitteln


git-svn-id: http://infon.googlecode.com/svn/trunk@123 8171fb75-e542-0410-96e4-03d5dd800671
  • Loading branch information...
1 parent a9eed7e commit 434e74ccbada30823a4043a8c811e597131111a4 @dividuum committed Dec 10, 2006
Showing with 48 additions and 14 deletions.
  1. +1 −1 Makefile
  2. +6 −5 client.rb
  3. +3 −1 client_creature.c
  4. +1 −0 client_creature.h
  5. +1 −0 common_world.h
  6. +1 −0 creature.c
  7. +4 −4 demo2graph.rb
  8. BIN example.demo
  9. +1 −0 infond.lua
  10. +1 −1 renderer.h
  11. +19 −1 sdl_gui.c
  12. +4 −0 sdl_sprite.c
  13. +5 −1 sdl_sprite.h
  14. +1 −0 world.c
View
@@ -107,7 +107,7 @@ win32-client-dist: $(GUI_EXECUTABLE) $(SDL_RENDERER)
/opt/xmingw/bin/i386-mingw32msvc-strip $^
upx -9 --all-methods $(GUI_EXECUTABLE)
upx -9 --all-methods $(SDL_RENDERER)
- zip infon-win32-r$(REVISION).zip README $^ gfx/*.fnt gfx/*.png example.demo
+ zip infon-win32-r$(REVISION).zip README $^ gfx/*.fnt gfx/*.png
linux-client-dist: $(GUI_EXECUTABLE) $(SDL_RENDERER) $(NULL_RENDERER)
strip $^
View
@@ -63,9 +63,10 @@ def readXX(len)
end
loop do
- len = socket.read8
- print "len=%3d " % len
- case type = socket.read8
+ len = socket.read8
+ type = socket.read8
+ print "type=%3d len=%3d " % [type, len]
+ case type
when 0:
print "player upd: "
print "pno=%d " % socket.read8
@@ -77,7 +78,7 @@ def readXX(len)
print "score=%d " % (socket.read16 - 500) if mask & 16 != 0
puts
when 1:
- puts "%d, %d => %d " % [socket.read8, socket.read8, socket.read8]
+ puts "%d, %d => %d %d " % [socket.read8, socket.read8, socket.read8, socket.read8]
when 2:
puts "msg: %s " % socket.readXX(len)
when 3:
@@ -87,7 +88,7 @@ def readXX(len)
if mask & 1 != 0
print "alive=%s " % [socket.read8 == 0xFF ?
"dead" :
- "spawned %d,%d" % [socket.read16, socket.read16] ]
+ "spawned %d %d,%d" % [socket.read16, socket.read16, socket.read16] ]
end
print "type=%d " % socket.read8 if mask & 2 != 0
if mask & 4 != 0
View
@@ -183,12 +183,14 @@ void client_creature_from_network(packet_t *packet) {
if (playerno >= MAXPLAYERS) PROTOCOL_ERROR();
creature->player = playerno;
- uint16_t x, y;
+ uint16_t vm_id, x, y;
+ if (!packet_read16(packet, &vm_id)) PROTOCOL_ERROR();
if (!packet_read16(packet, &x)) PROTOCOL_ERROR();
if (!packet_read16(packet, &y)) PROTOCOL_ERROR();
creature->last_x = x;
creature->last_y = y;
+ creature->vm_id = vm_id;
creature->num = creatureno;
creature->x = x * CREATURE_POS_RESOLUTION;
creature->y = y * CREATURE_POS_RESOLUTION;
View
@@ -35,6 +35,7 @@ struct client_pathnode_s {
typedef struct client_creature_s {
int num;
+ int vm_id;
int used;
void *userdata;
View
@@ -44,6 +44,7 @@ typedef enum {
TILE_GFX_LAVA,
TILE_GFX_NONE,
TILE_GFX_KOTH,
+ TILE_GFX_DESERT,
TILE_GFX_LAST_DEFINED
} mapgfx_e;
View
@@ -982,6 +982,7 @@ void creature_to_network(creature_t *creature, int dirtymask, client_t *client)
if (dirtymask & CREATURE_DIRTY_ALIVE) {
if (CREATURE_USED(creature)) {
packet_write08(&packet, player_num(creature->player));
+ packet_write16(&packet, creature->vm_id);
packet_write16(&packet, creature->network_last_x = creature->network_path_x);
packet_write16(&packet, creature->network_last_y = creature->network_path_y);
} else {
View
@@ -10,9 +10,9 @@ def initialize(type, gfx, food)
end
class Creature
- attr_accessor :type, :state, :food, :health, :target, :message, :speed, :x, :y, :id, :player
- def initialize(player, x, y)
- @player, @x, @y = player, x, y
+ attr_accessor :type, :state, :food, :health, :target, :message, :speed, :x, :y, :id, :player, :vm_id
+ def initialize(player, vm_id, x, y)
+ @player, @vm_id, @x, @y = player, vm_id, x, y
end
end
@@ -119,7 +119,7 @@ def tick
if pno == 0xFF
@creatures.delete(cno)
else
- creature = @creatures[cno] = Creature.new(pno, @file.read16, @file.read16)
+ creature = @creatures[cno] = Creature.new(pno, @file.read16, @file.read16, @file.read16)
creature.id = cno
end
else
View
Binary file not shown.
View
@@ -368,6 +368,7 @@ function world_load(map)
TILE_GFX_LAVA = TILE_GFX_LAVA;
TILE_GFX_NONE = TILE_GFX_NONE;
TILE_GFX_KOTH = TILE_GFX_KOTH;
+ TILE_GFX_DESERT = TILE_GFX_DESERT;
}
-- activate environment for world code and load world
View
@@ -29,7 +29,7 @@ extern "C" {
#include "client_player.h"
#include "client_world.h"
-#define RENDERER_API_VERSION 3
+#define RENDERER_API_VERSION 4
typedef struct {
/* the renderer version number. set this to RENDERER_API_VERSION. */
View
@@ -49,6 +49,8 @@ static int offset_y;
static struct evbuffer *scrollbuffer;
static int rand_table[256];
+static int debug = 0;
+
static void recenter() {
const client_world_info_t *info = infon->get_world_info();
if (!info) return;
@@ -66,6 +68,7 @@ static void handle_events() {
if (event.key.keysym.mod & KMOD_ALT)
video_fullscreen_toggle();
break;
+ case SDLK_F12: debug ^= 1; break;
case SDLK_1: video_resize( 640, 480); break;
case SDLK_2: video_resize( 800, 600); break;
case SDLK_3: video_resize(1024, 768); break;
@@ -161,6 +164,14 @@ static void draw_creature(const client_creature_t *creature, void *opaque) {
}
video_tiny(x - strlen(creature->message) * 6 / 2 + 9, y + 14, creature->message);
+
+ if (debug) {
+ char tmp[128];
+ snprintf(tmp, sizeof(tmp), "%d(%d) p%d", creature->vm_id, creature->num, creature->player);
+ video_tiny(x, y + 20, tmp);
+ snprintf(tmp, sizeof(tmp), "f=%d h=%d", creature->food, creature->health);
+ video_tiny(x, y + 28, tmp);
+ }
if (creature->state == CREATURE_ATTACK) {
const client_creature_t *target = infon->get_creature(creature->target);
@@ -358,10 +369,17 @@ static void draw_world() {
case TILE_GFX_KOTH:
floor_sprite = SPRITE_KOTH;
break;
+ case TILE_GFX_DESERT:
+ floor_sprite = SPRITE_DESERT + pos_rand % SPRITE_NUM_DESERT;
+ break;
default:
- floor_sprite = SPRITE_KOTH;
+ floor_sprite = -1;
+ break;
}
+ if (debug)
+ floor_sprite = tile->type == TILE_PLAIN ? SPRITE_SNOW_PLAIN : -1;
+
if (floor_sprite < 0)
video_rect(screenx, screeny, screenx + SPRITE_TILE_SIZE, screeny + SPRITE_TILE_SIZE, 30, 30, 30, 0);
else
View
@@ -75,6 +75,10 @@ static void sprite_load_background() {
{ 0, 6 }, { 1, 6 }, { 2, 6 }, { 3, 6 },
// Lava
{ 0, 7 }, { 1, 7 }, { 2, 7 }, { 3, 7 },
+ // Desert
+ { 6, 3 }, { 7, 3 }, { 8, 3 }, { 9, 3 },
+ { 10, 3 }, { 11, 3 }, { 12, 3 }, { 13, 3 },
+ { 14, 3 }, { 15, 3 },
};
for (int i = 0; i < SPRITE_NUM_TILES; i++) {
View
@@ -55,6 +55,9 @@
#define SPRITE_LAVA (SPRITE_WATER + SPRITE_NUM_WATER)
#define SPRITE_NUM_LAVA 4
+#define SPRITE_DESERT (SPRITE_LAVA + SPRITE_NUM_LAVA)
+#define SPRITE_NUM_DESERT 10
+
#define SPRITE_NUM_TILES (SPRITE_NUM_SOLID + \
SPRITE_NUM_PLAIN + \
SPRITE_NUM_BORDER + \
@@ -63,7 +66,8 @@
SPRITE_NUM_SNOW_BORDER + \
SPRITE_NUM_KOTH + \
SPRITE_NUM_WATER + \
- SPRITE_NUM_LAVA)
+ SPRITE_NUM_LAVA + \
+ SPRITE_NUM_DESERT)
#define SPRITE_TILE_SIZE 16
View
@@ -310,6 +310,7 @@ void world_init() {
lua_register_constant(L, TILE_GFX_LAVA);
lua_register_constant(L, TILE_GFX_NONE);
lua_register_constant(L, TILE_GFX_KOTH);
+ lua_register_constant(L, TILE_GFX_DESERT);
lua_register_constant(L, TILE_WIDTH);
lua_register_constant(L, TILE_HEIGHT);

0 comments on commit 434e74c

Please sign in to comment.