Skip to content

Commit

Permalink
Merge branch 'vanilla' into PR-30
Browse files Browse the repository at this point in the history
  • Loading branch information
giulianobelinassi authored May 31, 2024
2 parents 28484b6 + c2d93fe commit ce77668
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions common/irandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <stdlib.h>
#include <time.h>
#include "irandom.h"
#include "endianness.h"

unsigned int RandNumb = 0x12349876;

Expand Down Expand Up @@ -59,6 +60,18 @@ unsigned char Random()
** This treats the number as bytes so setting it on bit endian machines needs to byte swap.
*/
unsigned char* bytes = reinterpret_cast<unsigned char*>(&RandNumb);
#ifdef __BIG_ENDIAN__
unsigned char cf1 = (bytes[3] >> 1) & 1;
unsigned char tmp_a = bytes[3] >> 2;
unsigned char cf2 = (bytes[1] >> 7) & 1;
bytes[1] = (bytes[1] << 1) | cf1;
cf1 = (bytes[2] >> 7) & 1;
bytes[2] = (bytes[2] << 1) | cf2;
cf2 = (tmp_a - (RandNumb + (cf1 != 1))) & 1;
bytes[3] = (bytes[3] >> 1) | (cf2 << 7);

return bytes[2] ^ bytes[3];
#else
unsigned char cf1 = (bytes[0] >> 1) & 1;
unsigned char tmp_a = bytes[0] >> 2;
unsigned char cf2 = (bytes[2] >> 7) & 1;
Expand All @@ -69,6 +82,7 @@ unsigned char Random()
bytes[0] = (bytes[0] >> 1) | (cf2 << 7);

return bytes[1] ^ bytes[0];
#endif
}

int Get_Random_Mask(int maxval)
Expand Down
6 changes: 6 additions & 0 deletions tiberiandawn/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled)
useGoldStyle = Settings.Video.ButtonStyle == 1;
}

/* If DOSMode is enabled then force disable of goldstyle buttons once the
textures may not be available. */
if (Get_Resolution_Factor() == 0) {
useGoldStyle = false;
}

w--;
h--;
BoxStyleType const& style = useGoldStyle ? ButtonColorsGold[up] : ButtonColorsClassic[up];
Expand Down

0 comments on commit ce77668

Please sign in to comment.