Skip to content

Commit

Permalink
Use C4Real instead of C4Fixed where representation is irrelevant
Browse files Browse the repository at this point in the history
While C4Real is just a typedef for C4Fixed, it signifies more clearly
that we don't care about the memory representation at the point of use.
  • Loading branch information
isilkor committed Apr 19, 2017
1 parent 7c444e7 commit fc1a7a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/game/C4GameScript.cpp
Expand Up @@ -902,7 +902,7 @@ static bool FnSetPlayerZoom(C4PropList * _this, long plr_idx, long zoom, long pr
{
// zoom factor calculation
if (!precision) precision = 1;
C4Fixed fZoom = itofix(zoom, precision);
C4Real fZoom = itofix(zoom, precision);
// safety check on player only, so function return result is always in sync
C4Player *plr = ::Players.Get(plr_idx);
if (!plr) return false;
Expand Down
8 changes: 4 additions & 4 deletions src/player/C4Player.cpp
Expand Up @@ -1818,19 +1818,19 @@ void C4Player::SetMaxZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool
ZoomLimitsToViewports();
}

void C4Player::SetZoom(C4Fixed zoom, bool direct, bool no_increase, bool no_decrease)
void C4Player::SetZoom(C4Real zoom, bool direct, bool no_increase, bool no_decrease)
{
AdjustZoomParameter(&ZoomVal, zoom, no_increase, no_decrease);
ZoomToViewports(direct, no_increase, no_decrease);
}

void C4Player::SetMinZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
void C4Player::SetMinZoom(C4Real zoom, bool no_increase, bool no_decrease)
{
AdjustZoomParameter(&ZoomLimitMinVal, zoom, no_increase, no_decrease);
ZoomLimitsToViewports();
}

void C4Player::SetMaxZoom(C4Fixed zoom, bool no_increase, bool no_decrease)
void C4Player::SetMaxZoom(C4Real zoom, bool no_increase, bool no_decrease)
{
AdjustZoomParameter(&ZoomLimitMaxVal, zoom, no_increase, no_decrease);
ZoomLimitsToViewports();
Expand Down Expand Up @@ -1882,7 +1882,7 @@ bool C4Player::AdjustZoomParameter(int32_t *range_par, int32_t new_val, bool no_
return true;
}

bool C4Player::AdjustZoomParameter(C4Fixed *zoom_par, C4Fixed new_val, bool no_increase, bool no_decrease)
bool C4Player::AdjustZoomParameter(C4Real *zoom_par, C4Real new_val, bool no_increase, bool no_decrease)
{
// helper function: Adjust *zoom_par to new_val if increase/decrease not forbidden
if (new_val < *zoom_par)
Expand Down
10 changes: 5 additions & 5 deletions src/player/C4Player.h
Expand Up @@ -112,7 +112,7 @@ class C4Player: public C4PlayerInfoCore
int32_t FlashCom; // NoSave //
bool fFogOfWar;
int32_t ZoomLimitMinWdt,ZoomLimitMinHgt,ZoomLimitMaxWdt,ZoomLimitMaxHgt,ZoomWdt,ZoomHgt; // zoom limits and last zoom set by script
C4Fixed ZoomLimitMinVal,ZoomLimitMaxVal,ZoomVal; // direct zoom values.
C4Real ZoomLimitMinVal,ZoomLimitMaxVal,ZoomVal; // direct zoom values.
// Game
int32_t Wealth;
int32_t CurrentScore,InitialScore;
Expand Down Expand Up @@ -254,17 +254,17 @@ class C4Player: public C4PlayerInfoCore
void SetZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool direct, bool no_increase, bool no_decrease);
void SetMinZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease);
void SetMaxZoomByViewRange(int32_t range_wdt, int32_t range_hgt, bool no_increase, bool no_decrease);
void SetZoom(C4Fixed zoom, bool direct, bool no_increase, bool no_decrease);
void SetMinZoom(C4Fixed zoom, bool no_increase, bool no_decrease);
void SetMaxZoom(C4Fixed zoom, bool no_increase, bool no_decrease);
void SetZoom(C4Real zoom, bool direct, bool no_increase, bool no_decrease);
void SetMinZoom(C4Real zoom, bool no_increase, bool no_decrease);
void SetMaxZoom(C4Real zoom, bool no_increase, bool no_decrease);
void ZoomToViewports(bool direct, bool no_increase=false, bool no_decrease=false);
void ZoomToViewport(C4Viewport* vp, bool direct, bool no_increase=false, bool no_decrease=false);
void ZoomLimitsToViewports();
void ZoomLimitsToViewport(C4Viewport* vp);

private:
bool AdjustZoomParameter(int32_t *range_par, int32_t new_val, bool no_increase, bool no_decrease);
bool AdjustZoomParameter(C4Fixed *zoom_par, C4Fixed new_val, bool no_increase, bool no_decrease);
bool AdjustZoomParameter(C4Real *zoom_par, C4Real new_val, bool no_increase, bool no_decrease);

// Finds a new gamepad to use, returning true on success.
bool FindGamepad();
Expand Down

0 comments on commit fc1a7a5

Please sign in to comment.