diff --git a/src/game/replay.cpp b/src/game/replay.cpp index bcbe44b17..cb3095df2 100644 --- a/src/game/replay.cpp +++ b/src/game/replay.cpp @@ -50,6 +50,7 @@ #include "network.h" #include "interface.h" #include "actions.h" +#include "sound.h" //---------------------------------------------------------------------------- // Structures @@ -881,6 +882,9 @@ static void DoNextReplay() } else { HandleCheats(val); } + } else if (!strcmp(action, "chat")) { + SetMessage("%s", val); + PlayGameSound(GameSounds.ChatMessage.Sound, MaxSampleVolume); } else if (!strcmp(action, "quit")) { CommandQuit(arg1); } else { diff --git a/src/map/map_draw.cpp b/src/map/map_draw.cpp index 065c1bf94..15b42dad9 100644 --- a/src/map/map_draw.cpp +++ b/src/map/map_draw.cpp @@ -277,6 +277,7 @@ void CViewport::DrawMapBackgroundInViewport() const Map.TileGraphic->DrawFrameClip(tile, dx, dy); #ifdef DEBUG +#ifdef DEBUGMAPDRAW int my_mask = 0; unsigned int color = 0; if (Map.CheckMask(sx, MapFieldUnpassable)) { @@ -308,6 +309,7 @@ void CViewport::DrawMapBackgroundInViewport() const Map.Fields[sx].TilesetTile); } +#endif #endif ++sx; dx += PixelTileSize.x; diff --git a/src/map/map_save.cpp b/src/map/map_save.cpp index a3cd688c9..93930dc59 100644 --- a/src/map/map_save.cpp +++ b/src/map/map_save.cpp @@ -82,10 +82,7 @@ void CMap::Save(CFile &file) const for (int w = 0; w < this->Info.MapWidth; ++w) { const CMapField &mf = *this->Field(w, h); - file.printf(" {%3d, %3d,", mf.Tile, mf.SeenTile); - if (mf.Value) { - file.printf(" %d,", mf.Value); - } + file.printf(" {%3d, %3d, %2d, %2d,", mf.Tile, mf.SeenTile, mf.Value, mf.Cost); for (int i = 0; i < PlayerMax; ++i) { if (mf.Visible[i] == 1) { file.printf(" \"explored\", %d,", i); diff --git a/src/map/script_map.cpp b/src/map/script_map.cpp index f14b2cb70..08f85d980 100644 --- a/src/map/script_map.cpp +++ b/src/map/script_map.cpp @@ -158,13 +158,16 @@ static int CclStratagusMap(lua_State *l) Map.Fields[i].SeenTile = LuaToNumber(l, -1); lua_pop(l, 1); ++j2; + lua_rawgeti(l, -1, j2 + 1); + Map.Fields[i].Value = LuaToNumber(l, -1); + lua_pop(l, 1); + ++j2; + lua_rawgeti(l, -1, j2 + 1); + Map.Fields[i].Cost = LuaToNumber(l, -1); + lua_pop(l, 1); + ++j2; for (; j2 < args2; ++j2) { lua_rawgeti(l, -1, j2 + 1); - if (lua_isnumber(l, -1)) { - Map.Fields[i].Value = LuaToNumber(l, -1); - lua_pop(l, 1); - continue; - } value = LuaToString(l, -1); lua_pop(l, 1); if (!strcmp(value, "explored")) { diff --git a/src/missile/missile_cliptotarget.cpp b/src/missile/missile_cliptotarget.cpp index ebd6f0201..7fbf9b497 100644 --- a/src/missile/missile_cliptotarget.cpp +++ b/src/missile/missile_cliptotarget.cpp @@ -53,7 +53,9 @@ void MissileClipToTarget::Action() } if (this->NextMissileFrame(1, 0)) { - this->MissileHit(); + if (this->SourceUnit && this->SourceUnit->IsAliveOnMap()) { + this->MissileHit(); + } this->TTL = 0; } } diff --git a/src/network/network.cpp b/src/network/network.cpp index 2d70b6edf..f3e5a046a 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1168,6 +1168,7 @@ static void ParseNetworkCommand(const CNetworkCommandQueue *ncq) NetMsgBuf[ply][127] = '\0'; SetMessage("%s", NetMsgBuf[ply]); PlayGameSound(GameSounds.ChatMessage.Sound, MaxSampleVolume); + CommandLog("chat", NoUnitP, FlushCommands, -1, -1, NoUnitP, NetMsgBuf[ply], -1); NetMsgBufLen[ply] = 0; } } diff --git a/src/stratagus/player.cpp b/src/stratagus/player.cpp index abf36e3d9..360999007 100644 --- a/src/stratagus/player.cpp +++ b/src/stratagus/player.cpp @@ -867,9 +867,9 @@ void CPlayer::SetResource(int resource, int value, int type) { if (type == STORE_BOTH) { if (this->MaxResources[resource] != -1) { - const int toStore = std::min(0, value - this->Resources[resource]); - this->StoredResources[resource] = std::min(toStore, this->MaxResources[resource]); - this->Resources[resource] = std::max(0, value - toStore); + const int toRes = std::max(0, value - this->StoredResources[resource]); + this->Resources[resource] = std::max(0, toRes); + this->StoredResources[resource] = std::min(value - toRes, this->MaxResources[resource]); } else { this->Resources[resource] = value; } @@ -960,7 +960,7 @@ int CPlayer::CheckCosts(const int *costs) const Notify(_("Not enough %s...%s more %s."), name, actionName, name); err |= 1 << i; - if (GameSounds.NotEnoughRes[this->Race][i].Sound) { + if (this == ThisPlayer && GameSounds.NotEnoughRes[this->Race][i].Sound) { PlayGameSound(GameSounds.NotEnoughRes[this->Race][i].Sound, MaxSampleVolume); } } diff --git a/src/stratagus/script_player.cpp b/src/stratagus/script_player.cpp index 839c1e4f2..5a0691a05 100644 --- a/src/stratagus/script_player.cpp +++ b/src/stratagus/script_player.cpp @@ -339,7 +339,7 @@ void CPlayer::Load(lua_State *l) // Manage max for (int i = 0; i < MaxCosts; ++i) { if (this->MaxResources[i] != -1) { - this->SetResource(i, this->StoredResources[i]); + this->SetResource(i, this->Resources[i] + this->StoredResources[i], STORE_BOTH); } } } diff --git a/src/video/font.cpp b/src/video/font.cpp index d355eb9ea..763bcc2aa 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -504,6 +504,7 @@ int CFont::Width(const int number) const int utf8; size_t pos = 0; const CFontColor *backup = fc; + bool isReverse = false; font->DynamicLoad(); CGraphic *g = font->GetFontColorGraphic(FontColor); @@ -526,6 +527,7 @@ int CFont::Width(const int number) const case '<': LastTextColor = (CFontColor *)fc; if (fc != reverse) { + isReverse = true; fc = reverse; g = font->GetFontColorGraphic(fc); } @@ -534,6 +536,7 @@ int CFont::Width(const int number) const case '>': if (fc != LastTextColor) { const CFontColor *rev = LastTextColor; // swap last and current color + isReverse = false; LastTextColor = (CFontColor *)fc; fc = rev; g = font->GetFontColorGraphic(fc); @@ -566,7 +569,7 @@ int CFont::Width(const int number) const widths += font->DrawChar<CLIP>(g, utf8, x + widths, y, fc); - if (fc != backup) { + if (isReverse == false && fc != backup) { fc = backup; if (UseOpenGL) { g = FontColorGraphics[font][fc];