From 8648a321d7be0c04a5afba04062b7ef8f9edd9e0 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Mon, 4 Jan 2010 01:39:37 +0000 Subject: [PATCH] fix git-svn-id: http://svn.net-core.org/repos/t-engine4@192 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/Map.lua | 10 +++++-- game/engine/Target.lua | 4 +-- game/modules/tome/class/Game.lua | 24 +++++++--------- src/core_lua.c | 48 +++++++++++++++----------------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/game/engine/Map.lua b/game/engine/Map.lua index 1ae1ec1d6b..f1787fd9ad 100644 --- a/game/engine/Map.lua +++ b/game/engine/Map.lua @@ -33,9 +33,15 @@ function _M:setViewPort(x, y, w, h, tile_w, tile_h, fontname, fontsize, multidis self.multidisplay = multidisplay self.display_x, self.display_y = x, y self.viewport = {width=w, height=h, mwidth=math.floor(w/tile_w), mheight=math.floor(h/tile_h)} - self.tiles = Tiles.new(tile_w, tile_h, fontname, fontsize, true) - self.tilesSurface = Tiles.new(tile_w, tile_h, fontname, fontsize, false) self.tile_w, self.tile_h = tile_w, tile_h + self.fontname, self.fontsize = fontname, fontsize + self:resetTiles() +end + +--- Create the tile repositories +function _M:resetTiles() + self.tiles = Tiles.new(self.tile_w, self.tile_h, self.fontname, self.fontsize, true) + self.tilesSurface = Tiles.new(self.tile_w, self.tile_h, self.fontname, self.fontsize, false) end --- Defines the faction of the person seeing the map diff --git a/game/engine/Target.lua b/game/engine/Target.lua index c57fc87cd9..3e6b1cf0d4 100644 --- a/game/engine/Target.lua +++ b/game/engine/Target.lua @@ -11,7 +11,7 @@ function _M:init(map, source_actor) self.active = false self.target_type = {} - self.cursor = core.display.loadImage(engine.Tiles.prefix.."target_cursor.png") + self.cursor = core.display.loadImage(engine.Tiles.prefix.."target_cursor.png"):glTexture() self.sr = core.display.newSurface(map.tile_w, map.tile_h) self.sr:erase(255, 0, 0, 90) @@ -54,7 +54,7 @@ function _M:display() s:toScreen(self.display_x + (lx - game.level.map.mx) * self.tile_w, self.display_y + (ly - game.level.map.my) * self.tile_h) lx, ly = l() end - self.cursor:toScreen(self.display_x + (self.target.x - game.level.map.mx) * self.tile_w, self.display_y + (self.target.y - game.level.map.my) * self.tile_h) + self.cursor:toScreen(self.display_x + (self.target.x - game.level.map.mx) * self.tile_w, self.display_y + (self.target.y - game.level.map.my) * self.tile_h, self.tile_w, self.tile_h) if s == self.b then stopx, stopy = self.target.x, self.target.y end diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 60c230e578..e15ac847d3 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -101,27 +101,23 @@ function _M:setupDisplayMode() self.gfxmode = self.gfxmode or 1 if self.gfxmode == 1 then Map:setViewPort(200, 0, self.w - 200, math.floor(self.h * 0.80), 32, 32, nil, 20, true) - Map.tiles:clean() - Map.tiles.w = 32 - Map.tiles.h = 32 + Map:resetTiles() Map.tiles.use_images = true - game.level.map:recreate() + self.level.map:recreate() elseif self.gfxmode == 2 then Map:setViewPort(200, 0, self.w - 200, math.floor(self.h * 0.80), 16, 16, nil, 14, true) - Map.tiles:clean() - Map.tiles.w = 16 - Map.tiles.h = 16 + Map:resetTiles() Map.tiles.use_images = true - game.level.map:recreate() + self.level.map:recreate() elseif self.gfxmode == 3 then Map:setViewPort(200, 0, self.w - 200, math.floor(self.h * 0.80), 16, 16, nil, 14, false) - Map.tiles:clean() - Map.tiles.w = 16 - Map.tiles.h = 16 + Map:resetTiles() Map.tiles.use_images = false - game.level.map:recreate() + self.level.map:recreate() end - game.level.map:moveViewSurround(self.player.x, self.player.y, 8, 8) + self.target = Target.new(Map, self.player) + self.target.target.entity = self.player + self.level.map:moveViewSurround(self.player.x, self.player.y, 8, 8) end function _M:save() @@ -393,7 +389,7 @@ function _M:setupCommands() local ret = o:use(self.player) if ret and ret == "destroy" then self.player:removeObject(self.player:getInven(self.player.INVEN_INVEN), item) - game.log("You have no more "..o:getName()) + self.log("You have no more "..o:getName()) self.player:sortInven() end end diff --git a/src/core_lua.c b/src/core_lua.c index 4c3065e0c5..a945b83d90 100644 --- a/src/core_lua.c +++ b/src/core_lua.c @@ -409,42 +409,40 @@ static int sdl_new_tile(lua_State *L) SDL_Color color = {r,g,b}; SDL_Surface *txt = TTF_RenderUTF8_Blended(*f, str, color); - if (txt) - { - SDL_Surface **s = (SDL_Surface**)lua_newuserdata(L, sizeof(SDL_Surface*)); - auxiliar_setclass(L, "sdl{surface}", -1); - Uint32 rmask, gmask, bmask, amask; + SDL_Surface **s = (SDL_Surface**)lua_newuserdata(L, sizeof(SDL_Surface*)); + auxiliar_setclass(L, "sdl{surface}", -1); + + Uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; + rmask = 0xff000000; + gmask = 0x00ff0000; + bmask = 0x0000ff00; + amask = 0x000000ff; #else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0xff000000; #endif - *s = SDL_CreateRGBSurface( - SDL_SWSURFACE | SDL_SRCALPHA, - w, - h, - 32, - rmask, gmask, bmask, amask - ); + *s = SDL_CreateRGBSurface( + SDL_SWSURFACE | SDL_SRCALPHA, + w, + h, + 32, + rmask, gmask, bmask, amask + ); - SDL_SetAlpha(txt, 0, 0); - SDL_FillRect(*s, NULL, SDL_MapRGBA((*s)->format, br, bg, bb, alpha)); + SDL_FillRect(*s, NULL, SDL_MapRGBA((*s)->format, br, bg, bb, alpha)); + if (txt) + { + SDL_SetAlpha(txt, 0, 0); sdlDrawImage(*s, txt, x, y); SDL_FreeSurface(txt); - - return 1; } - lua_pushnil(L); return 1; } -- GitLab