(svn r11216) -Codechange: Protect the callback who would access var 45 against a randomness that could eventually cause desynchs. Instead, use a controlled random value.

This commit is contained in:
belugas 2007-10-06 00:23:30 +00:00
parent df9392a737
commit 6f7f7afba4

View File

@ -213,16 +213,20 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
/* player info */ /* player info */
case 0x45: { case 0x45: {
byte colour1, colour2; ///< Not initializing these two will give some kind of random byte colours;
bool is_ai = false; bool is_ai = false;
if (IsValidPlayer(industry->founder)) { if (IsValidPlayer(industry->founder)) {
const Player *p = GetPlayer(industry->founder); const Player *p = GetPlayer(industry->founder);
const Livery *l = &p->livery[LS_DEFAULT]; const Livery *l = &p->livery[LS_DEFAULT];
is_ai = p->is_ai; is_ai = p->is_ai;
colour1 = l->colour1; colours = l->colour1 + l->colour2 * 16;
colour2 = l->colour2; } else {
colours = GB(Random(), 0, 8);
} }
return industry->founder | (is_ai ? 0x10000 : 0) | ((colour1 + colour2 * 16) << 24);
return industry->founder | (is_ai ? 0x10000 : 0) | (colours << 24);
} }
/* Get industry ID at offset param */ /* Get industry ID at offset param */