Skip to content

Commit

Permalink
Retrieve Color Count from Vehicle Info
Browse files Browse the repository at this point in the history
  • Loading branch information
KcRobin9 committed Mar 19, 2024
1 parent 7950e6c commit a06281d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions code/midtown/mmai/aiVehicleOpponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ define_dummy_symbol(mmai_aiVehicleOpponent);
#include "agi/dlptmpl.h"
#include "agi/getdlp.h"
#include "agiworld/quality.h"
#include "data7/str.h"
#include "mmcityinfo/vehinfo.h"
#include "mmcityinfo/vehlist.h"

#include "aiData.h"
#include "aiGoalBackup.h"
#include "aiGoalFollowWayPts.h"
#include "aiGoalStop.h"

static mem::cmd_param PARAM_opponent_color_count {"colorcount"};
static mem::cmd_param PARAM_opp_color_count {"colorcount"};

void aiVehicleOpponent::DrawDamage()
{}
Expand All @@ -40,10 +43,10 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
if (agiRQ.TextureQuality)
--agiRQ.TextureQuality;

i32 paint_job = opp_id % PARAM_opponent_color_count.get_or(4);
i32 index = opp_id + 1;
OpponentRaceData* opp = static_cast<OpponentRaceData*>(race_data->Opponents.Access(opp_id + 1));

OpponentRaceData* opp = static_cast<OpponentRaceData*>(race_data->Opponents.Access(index));
mmVehInfo* veh_info = VehList()->GetVehicleInfo(opp->Model);
i32 paint_job = opp_id % PARAM_opp_color_count.get_or(string(veh_info->Colors).NumSubStrings());

Car.Init(opp->Model, CAR_TYPE_OPPONENT, paint_job);

Expand All @@ -54,9 +57,7 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)

WayPts = arnew aiGoalFollowWayPts(
opp->PathFile, &RailSet, this, &IsBackup, &IsFinished, &IsStopped, xconst(race_name), opp->MaxThrottle);

BackupGoal = arnew aiGoalBackup(&RailSet, &Car, &IsBackup);

StopGoal = arnew aiGoalStop(&Car, &IsStopped);

IsSemi = !std::strcmp("vpsemi", opp->Model);
Expand All @@ -73,5 +74,6 @@ void aiVehicleOpponent::Init(i32 opp_id, aiRaceData* race_data, char* race_name)
RailSet.BackBumperDist = max.z;
RailSet.RSideDist = max.x;
}

AudIndexNumber = -1;
}

0 comments on commit a06281d

Please sign in to comment.