Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pierre Kim
OpenRCT2-mod
Commits
45968272
Commit
45968272
authored
7 years ago
by
Michael Steenbeek
Browse files
Options
Download
Email Patches
Plain Diff
Reformat MoneyEffect.cpp
parent
a050c694
develop
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/openrct2/world/MoneyEffect.cpp
+52
-39
src/openrct2/world/MoneyEffect.cpp
with
52 additions
and
39 deletions
+52
-39
src/openrct2/world/MoneyEffect.cpp
+
52
-
39
View file @
45968272
...
...
@@ -21,10 +21,10 @@
#include "sprite.h"
static
const
LocationXY16
_moneyEffectMoveOffset
[]
=
{
{
1
,
-
1
},
{
1
,
1
},
{
-
1
,
1
},
{
-
1
,
-
1
}
{
1
,
-
1
},
{
1
,
1
},
{
-
1
,
1
},
{
-
1
,
-
1
}
};
/**
...
...
@@ -33,35 +33,35 @@ static const LocationXY16 _moneyEffectMoveOffset[] = {
*/
void
money_effect_create_at
(
money32
value
,
sint32
x
,
sint32
y
,
sint32
z
,
bool
vertical
)
{
if
(
value
==
MONEY
(
0
,
00
))
if
(
value
==
MONEY
(
0
,
00
))
return
;
rct_money_effect
*
moneyEffect
=
(
rct_money_effect
*
)
create_sprite
(
2
);
if
(
moneyEffect
==
NULL
)
rct_money_effect
*
moneyEffect
=
(
rct_money_effect
*
)
create_sprite
(
2
);
if
(
moneyEffect
==
nullptr
)
return
;
moneyEffect
->
value
=
value
;
moneyEffect
->
vertical
=
(
vertical
?
1
:
0
);
moneyEffect
->
var_14
=
64
;
moneyEffect
->
var_09
=
20
;
moneyEffect
->
var_15
=
30
;
moneyEffect
->
value
=
value
;
moneyEffect
->
vertical
=
(
vertical
?
1
:
0
);
moneyEffect
->
var_14
=
64
;
moneyEffect
->
var_09
=
20
;
moneyEffect
->
var_15
=
30
;
moneyEffect
->
sprite_identifier
=
SPRITE_IDENTIFIER_MISC
;
sprite_move
(
x
,
y
,
z
,
(
rct_sprite
*
)
moneyEffect
);
moneyEffect
->
misc_identifier
=
SPRITE_MISC_MONEY_EFFECT
;
moneyEffect
->
num_movements
=
0
;
moneyEffect
->
move_delay
=
0
;
sprite_move
(
x
,
y
,
z
,
(
rct_sprite
*
)
moneyEffect
);
moneyEffect
->
misc_identifier
=
SPRITE_MISC_MONEY_EFFECT
;
moneyEffect
->
num_movements
=
0
;
moneyEffect
->
move_delay
=
0
;
sint16
offsetX
=
0
;
if
(
!
gOpenRCT2NoGraphics
)
{
if
(
!
gOpenRCT2NoGraphics
)
{
// Construct string to display
rct_string_id
stringId
=
money_effect_get_string_id
(
moneyEffect
,
&
value
);
char
buffer
[
128
];
format_string
(
buffer
,
128
,
stringId
,
&
value
);
gCurrentFontSpriteBase
=
FONT_SPRITE_BASE_MEDIUM
;
offsetX
=
-
(
gfx_get_string_width
(
buffer
)
/
2
);
offsetX
=
-
(
gfx_get_string_width
(
buffer
)
/
2
);
}
moneyEffect
->
offset_x
=
offsetX
;
moneyEffect
->
wiggle
=
0
;
}
...
...
@@ -71,24 +71,26 @@ void money_effect_create_at(money32 value, sint32 x, sint32 y, sint32 z, bool ve
*/
void
money_effect_create
(
money32
value
)
{
LocationXYZ16
mapPosition
=
{
.
x
=
gCommandPosition
.
x
,
.
y
=
gCommandPosition
.
y
,
.
z
=
gCommandPosition
.
z
LocationXYZ16
mapPosition
=
{
gCommandPosition
.
x
,
gCommandPosition
.
y
,
gCommandPosition
.
z
};
if
(
mapPosition
.
x
==
LOCATION_NULL
)
{
rct_window
*
mainWindow
=
window_get_main
();
if
(
mainWindow
==
NULL
)
if
(
mapPosition
.
x
==
LOCATION_NULL
)
{
rct_window
*
mainWindow
=
window_get_main
();
if
(
mainWindow
==
nullptr
)
return
;
rct_viewport
*
mainViewport
=
mainWindow
->
viewport
;
rct_viewport
*
mainViewport
=
mainWindow
->
viewport
;
screen_get_map_xy
(
mainViewport
->
x
+
(
mainViewport
->
width
/
2
),
mainViewport
->
y
+
(
mainViewport
->
height
/
2
),
&
mapPosition
.
x
,
&
mapPosition
.
y
,
NULL
nullptr
);
if
(
mapPosition
.
x
==
LOCATION_NULL
)
return
;
...
...
@@ -103,48 +105,59 @@ void money_effect_create(money32 value)
*
* rct2: 0x00673232
*/
void
money_effect_update
(
rct_money_effect
*
moneyEffect
)
void
money_effect_update
(
rct_money_effect
*
moneyEffect
)
{
invalidate_sprite_2
((
rct_sprite
*
)
moneyEffect
);
invalidate_sprite_2
((
rct_sprite
*
)
moneyEffect
);
moneyEffect
->
wiggle
++
;
if
(
moneyEffect
->
wiggle
>=
22
)
{
moneyEffect
->
wiggle
=
0
;
}
moneyEffect
->
move_delay
++
;
if
(
moneyEffect
->
move_delay
<
2
)
{
return
;
}
sint32
x
=
moneyEffect
->
x
;
sint32
y
=
moneyEffect
->
y
;
sint32
z
=
moneyEffect
->
z
;
moneyEffect
->
move_delay
=
0
;
if
(
moneyEffect
->
vertical
)
{
if
(
moneyEffect
->
vertical
)
{
z
+=
1
;
}
y
+=
_moneyEffectMoveOffset
[
get_current_rotation
()].
y
;
x
+=
_moneyEffectMoveOffset
[
get_current_rotation
()].
x
;
sprite_move
(
x
,
y
,
z
,
(
rct_sprite
*
)
moneyEffect
);
sprite_move
(
x
,
y
,
z
,
(
rct_sprite
*
)
moneyEffect
);
moneyEffect
->
num_movements
++
;
if
(
moneyEffect
->
num_movements
<
55
)
{
return
;
}
sprite_remove
((
rct_sprite
*
)
moneyEffect
);
sprite_remove
((
rct_sprite
*
)
moneyEffect
);
}
rct_string_id
money_effect_get_string_id
(
const
rct_money_effect
*
sprite
,
money32
*
outValue
)
{
bool
vertical
=
(
sprite
->
vertical
!=
0
);
rct_string_id
spentStringId
=
vertical
?
STR_MONEY_EFFECT_SPEND_HIGHP
:
STR_MONEY_EFFECT_SPEND
;
bool
vertical
=
(
sprite
->
vertical
!=
0
);
rct_string_id
spentStringId
=
vertical
?
STR_MONEY_EFFECT_SPEND_HIGHP
:
STR_MONEY_EFFECT_SPEND
;
rct_string_id
receiveStringId
=
vertical
?
STR_MONEY_EFFECT_RECEIVE_HIGHP
:
STR_MONEY_EFFECT_RECEIVE
;
rct_string_id
stringId
=
receiveStringId
;
money32
value
=
sprite
->
value
;
if
(
value
<
0
)
{
rct_string_id
stringId
=
receiveStringId
;
money32
value
=
sprite
->
value
;
if
(
value
<
0
)
{
value
*=
-
1
;
stringId
=
spentStringId
;
}
if
(
outValue
!=
NULL
)
*
outValue
=
value
;
if
(
outValue
!=
nullptr
)
{
*
outValue
=
value
;
}
return
stringId
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help