|
 |
|
|
|
|
|
GTA Modification Forums
string ini
 |
|
 |
| |
Deji  |
Posted: Saturday, Apr 21 2012, 02:52
|
Coding like a Rockstar!

Group: Members
Joined: Dec 24, 2007


|
And to optimise even further... | CODE | :isPlayerDrivingAppropriateVehicle // if // 0AB1: call_scm_func @isPlayerDrivingAppropriateVehicle 0 // then if Actor.DrivingPoliceVehicle($PLAYER_ACTOR) then else if 0AAB: file_exists "CLEO\PoliceDB.ini" then 0AF0: 1@ = get_int_from_ini_file PoliceDB section "Vehicles" key "1" 0AF0: 2@ = get_int_from_ini_file PoliceDB section "Vehicles" key "2" 0AF0: 3@ = get_int_from_ini_file PoliceDB section "Vehicles" key "3" 0AF0: 4@ = get_int_from_ini_file PoliceDB section "Vehicles" key "4" 0AF0: 5@ = get_int_from_ini_file PoliceDB section "Vehicles" key "5" if or Actor.DrivingVehicleType($PLAYER_ACTOR, 1@) Actor.DrivingVehicleType($PLAYER_ACTOR, 2@) Actor.DrivingVehicleType($PLAYER_ACTOR, 3@) Actor.DrivingVehicleType($PLAYER_ACTOR, 4@) Actor.DrivingVehicleType($PLAYER_ACTOR, 5@) then end end end 0AB2: ret 0 |
0485 and 059A don't do anything but return true and false respectively. They may have been commands which used to actually perform a proper check, but were removed at some point and replaced to just return a default value. So while the name is valid, it can be misleading. A good way to show this: | CODE | // this statement is false if and 0485: return_true 059A: return_false then end
// this statement is true if or 0485: return_true 859A: not return_false then end |
So they're just conditional commands which we use to forcefully set the condition result to make SCM Functions act like they can be used as conditions as a coding trick. Any other conditional command will also work, hence the reason the optimised code above works just as well. It could be optimised more by using low-constructs (and thus, not having an empty "then" block). There's always a point, though, where a tiny bit of optimisation isn't worth making the code less neat. This post has been edited by Deji on Saturday, Apr 21 2012, 02:54
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|