Merge branch 'master' of github.com:Wargus/stratagus
This commit is contained in:
commit
7ca9428b8d
6 changed files with 37 additions and 21 deletions
|
@ -255,6 +255,11 @@ static inline void IncreaseVariable(CUnit &unit, int index)
|
|||
{
|
||||
unit.Variable[index].Value += unit.Variable[index].Increase;
|
||||
clamp(&unit.Variable[index].Value, 0, unit.Variable[index].Max);
|
||||
|
||||
//if variable is HP and increase is negative, unit dies if HP reached 0
|
||||
if (index == HP_INDEX && unit.Variable[HP_INDEX].Value <= 0) {
|
||||
LetUnitDie(unit);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -186,7 +186,9 @@ static int CclGetNumUnitsAt(lua_State *l)
|
|||
|
||||
// Check the player
|
||||
if (plynr == -1 || plynr == unit.Player->Index) {
|
||||
++s;
|
||||
if (unit.IsAlive()) {
|
||||
++s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ void MapSight(const CPlayer &player, const Vec2i &pos, int w, int h, int range,
|
|||
// bottom hemi-cycle
|
||||
const int maxy = std::min(range, Map.Info.MapHeight - pos.y - h);
|
||||
for (int offsety = 0; offsety < maxy; ++offsety) {
|
||||
const int offsetx = isqrt(square(range + 1) - square(offsety) - 1);
|
||||
const int offsetx = isqrt(square(range + 1) - square(offsety + 1) - 1);
|
||||
const int minx = std::max(0, pos.x - offsetx);
|
||||
const int maxx = std::min(Map.Info.MapWidth, pos.x + w + offsetx);
|
||||
Vec2i mpos(minx, pos.y + h + offsety);
|
||||
|
|
|
@ -98,11 +98,19 @@ size_t serialize(unsigned char *buf, const std::string &s)
|
|||
buf += serialize16(buf, uint16_t(s.size()));
|
||||
memcpy(buf, s.c_str(), s.size());
|
||||
buf += s.size();
|
||||
//Wyrmgus start
|
||||
//Andrettin: fix to the multiplayer OOS issue - the fix works, but it would be better if someone reviewed the code! I am leaving the Wyrmgus tags on these changes until the code has been properly reviewed
|
||||
/*
|
||||
if ((s.size() & 0x03) != 0) {
|
||||
memset(buf, 0, s.size() & 0x03);
|
||||
}
|
||||
*/
|
||||
//Wyrmgus end
|
||||
}
|
||||
return 2 + ((s.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
//Wyrmgus start
|
||||
// return 2 + ((s.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
return 2 + (s.size() + 3);
|
||||
//Wyrmgus end
|
||||
}
|
||||
size_t serialize(unsigned char *buf, const std::vector<unsigned char> &data)
|
||||
{
|
||||
|
@ -113,11 +121,16 @@ size_t serialize(unsigned char *buf, const std::vector<unsigned char> &data)
|
|||
buf += serialize16(buf, uint16_t(data.size()));
|
||||
memcpy(buf, &data[0], data.size());
|
||||
buf += data.size();
|
||||
if ((data.size() & 0x03) != 0) {
|
||||
memset(buf, 0, data.size() & 0x03);
|
||||
}
|
||||
//Wyrmgus start
|
||||
// if ((data.size() & 0x03) != 0) {
|
||||
// memset(buf, 0, data.size() & 0x03);
|
||||
// }
|
||||
//Wyrmgus end
|
||||
}
|
||||
return 2 + ((data.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
//Wyrmgus start
|
||||
// return 2 + ((data.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
return 2 + (data.size() + 3);
|
||||
//Wyrmgus end
|
||||
}
|
||||
|
||||
size_t deserialize32(const unsigned char *buf, uint32_t *data)
|
||||
|
@ -162,7 +175,10 @@ size_t deserialize(const unsigned char *buf, std::string &s)
|
|||
|
||||
buf += deserialize16(buf, &size);
|
||||
s = std::string(reinterpret_cast<const char *>(buf), size);
|
||||
return 2 + ((s.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
//Wyrmgus start
|
||||
// return 2 + ((s.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
return 2 + (s.size() + 3);
|
||||
//Wyrmgus end
|
||||
}
|
||||
size_t deserialize(const unsigned char *buf, std::vector<unsigned char> &data)
|
||||
{
|
||||
|
@ -170,7 +186,10 @@ size_t deserialize(const unsigned char *buf, std::vector<unsigned char> &data)
|
|||
|
||||
buf += deserialize16(buf, &size);
|
||||
data.assign(buf, buf + size);
|
||||
return 2 + ((data.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
//Wyrmgus start
|
||||
// return 2 + ((data.size() + 3) & ~0x03); // round up to multiple of 4 for alignment.
|
||||
return 2 + (data.size() + 3);
|
||||
//Wyrmgus end
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1829,17 +1829,7 @@ void NetworkGamePrepareGameSettings()
|
|||
GameSettings.Presets[num[i]].Type = PlayerPerson;
|
||||
int v = ServerSetupState.Race[num[i]];
|
||||
if (v != 0) {
|
||||
int x = 0;
|
||||
|
||||
for (unsigned int n = 0; n < PlayerRaces.Count; ++n) {
|
||||
if (PlayerRaces.Visible[n]) {
|
||||
if (x + 1 == v) {
|
||||
break;
|
||||
}
|
||||
++x;
|
||||
}
|
||||
}
|
||||
GameSettings.Presets[num[i]].Race = x;
|
||||
GameSettings.Presets[num[i]].Race = v - 1;
|
||||
} else {
|
||||
GameSettings.Presets[num[i]].Race = SettingsPresetMapDefault;
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ bool CBuildRestrictionOnTop::Check(const CUnit *builder, const CUnitType &, cons
|
|||
if (it != cache.end() && (*it)->tilePos == pos) {
|
||||
CUnit &found = **it;
|
||||
std::vector<CUnit *> table;
|
||||
Vec2i endPos(found.tilePos.x + found.Type->TileWidth, found.tilePos.y + found.Type->TileHeight);
|
||||
Vec2i endPos(found.tilePos.x + found.Type->TileWidth - 1, found.tilePos.y + found.Type->TileHeight - 1);
|
||||
Select(found.tilePos, endPos, table);
|
||||
for (std::vector<CUnit *>::iterator it2 = table.begin(); it2 != table.end(); ++it2) {
|
||||
if (*it == *it2) {
|
||||
|
|
Loading…
Reference in a new issue