[+] Added ability to write chat messages into replay.

[*] Disabled map grid drawing in debug mode by default, use DEBUGMAPDRAW preprocessor variable to enable it.
[*] MissileClipToTarget now checks if attacker is alive when dealing a damage.
[-] Another bunch of fixes in MaxResources management.
[-] Play GameSounds.NotEnoughRes sounds only for this player.
[-] Fixed incorrect drawing of reverse font.
This commit is contained in:
iddqd-mail 2012-06-19 16:29:11 +06:00
parent 38a13f3b0b
commit 4469edffcd
9 changed files with 28 additions and 16 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -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);

View file

@ -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")) {

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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];