(svn r26670) [1.4] -Backport from trunk:

- Fix: CargoPacket::SourceStation() returns a StationID (r26660)
- Fix: Production cheat cannot be allowed to be active in multiplayer for desync reasons, even when activated in singleplayer previously [FS#6044] (r26656)
- Fix: Make sure an 'abs' is used that supports int64 when using 'abs' on those variables (r26651)
- Fix: Support save/load chunk lengths of up to (1 << 32) - 1 [FS#6041] (r26650)
This commit is contained in:
frosch 2014-07-01 20:13:23 +00:00
parent 13378995d9
commit 8dc0522434
4 changed files with 23 additions and 6 deletions

View File

@ -157,7 +157,7 @@ public:
* Gets the ID of the station where the cargo was loaded for the first time.
* @return StationID.
*/
inline SourceID SourceStation() const
inline StationID SourceStation() const
{
return this->source;
}

View File

@ -12,6 +12,7 @@
#ifndef OVERFLOWSAFE_TYPE_HPP
#define OVERFLOWSAFE_TYPE_HPP
#include "math_func.hpp"
/**
* Overflow safe template for integers, i.e. integers that will never overflow

View File

@ -24,6 +24,7 @@
#include "newgrf_industries.h"
#include "newgrf_text.h"
#include "newgrf_debug.h"
#include "network/network.h"
#include "strings_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"
@ -637,7 +638,8 @@ static inline bool IsProductionAlterable(const Industry *i)
{
const IndustrySpec *is = GetIndustrySpec(i->type);
return ((_game_mode == GM_EDITOR || _cheats.setup_prod.value) &&
(is->production_rate[0] != 0 || is->production_rate[1] != 0 || is->IsRawIndustry()));
(is->production_rate[0] != 0 || is->production_rate[1] != 0 || is->IsRawIndustry()) &&
!_networking);
}
class IndustryViewWindow : public Window

View File

@ -670,7 +670,11 @@ static uint SlReadSimpleGamma()
if (HasBit(i, 5)) {
i &= ~0x20;
if (HasBit(i, 4)) {
SlErrorCorrupt("Unsupported gamma");
i &= ~0x10;
if (HasBit(i, 3)) {
SlErrorCorrupt("Unsupported gamma");
}
i = SlReadByte(); // 32 bits only.
}
i = (i << 8) | SlReadByte();
}
@ -690,6 +694,11 @@ static uint SlReadSimpleGamma()
* 10xxxxxx xxxxxxxx
* 110xxxxx xxxxxxxx xxxxxxxx
* 1110xxxx xxxxxxxx xxxxxxxx xxxxxxxx
* 11110--- xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
* We could extend the scheme ad infinum to support arbitrarily
* large chunks, but as sizeof(size_t) == 4 is still very common
* we don't support anything above 32 bits. That's why in the last
* case the 3 most significant bits are unused.
* @param i Index being written
*/
@ -698,8 +707,13 @@ static void SlWriteSimpleGamma(size_t i)
if (i >= (1 << 7)) {
if (i >= (1 << 14)) {
if (i >= (1 << 21)) {
assert(i < (1 << 28));
SlWriteByte((byte)(0xE0 | (i >> 24)));
if (i >= (1 << 28)) {
assert(i <= UINT32_MAX); // We can only support 32 bits for now.
SlWriteByte((byte)(0xF0));
SlWriteByte((byte)(i >> 24));
} else {
SlWriteByte((byte)(0xE0 | (i >> 24)));
}
SlWriteByte((byte)(i >> 16));
} else {
SlWriteByte((byte)(0xC0 | (i >> 16)));
@ -715,7 +729,7 @@ static void SlWriteSimpleGamma(size_t i)
/** Return how many bytes used to encode a gamma value */
static inline uint SlGetGammaLength(size_t i)
{
return 1 + (i >= (1 << 7)) + (i >= (1 << 14)) + (i >= (1 << 21));
return 1 + (i >= (1 << 7)) + (i >= (1 << 14)) + (i >= (1 << 21)) + (i >= (1 << 28));
}
static inline uint SlReadSparseIndex()