Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ready] Garages #480

Merged
merged 3 commits into from May 24, 2018
Merged

[Ready] Garages #480

merged 3 commits into from May 24, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 20, 2018

#107

This PR todo list:

  • Garage controller
  • Rename garage type 11
  • Get rid of unused types
  • Cranes are not garages = fix opcodes
  • Resprays (basic stuff opening/closing)
  • Bomb shops (basic stuff opening/closing)
  • Hideout garages (basic stuff opening/closing)
  • Calculate distance to the closest door object in the world properly
  • Calculate distance between garage and player properly for hideout garages
  • Fix: some garages have incorrect min/max boundaries

Garages todo overall:

  • Free resprays
  • Bomb shops charge money
  • Bomb shops arm cars
  • Free bomb shops
  • Resprays fix cars
  • Resprays repaint cars
  • Resprays check for disallowed cars
  • Resprays charge money
  • Hideout garages store cars
  • Import/export garages
  • Import/export garages store cars
  • Special garage type 11 for missions
  • Special garage type 14 for missions
  • Special garage type 19 for missions
  • Special garage type 20 for missions
  • Special garage type 21 for missions
  • Restore from savefiles

@@ -249,6 +249,44 @@ class SimpleModelInfo : public BaseModelInfo {
return related_;
}

static bool isDoorModel(std::string m) {
if (m == "oddjgaragdoor") return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a way to separate the data here, the list of names can be std::(unordered_)set.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

@@ -76,6 +76,10 @@ GameWorld::~GameWorld() {
for (auto& p : allObjects) {
delete p;
}

for (auto& p : garageControllers) {
delete p;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing each controller in a unique_ptr would give you this for free.

o->getModelInfo<BaseModelInfo>()->name))
continue;

garageMidpoint.x = (coord0.x + coord1.x) / 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be calculated inside the loop

@@ -45,6 +45,13 @@ InstanceObject::InstanceObject(GameWorld* engine, const glm::vec3& pos,
engine->aigraph.createPathNodes(position, rot, path);
}
}

// @todo this is temporary, remove when physics gets fixed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What needs to be fixed about the doors?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to #450, I want to replace this code later with setStatic

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved

@ghost ghost changed the title [WIP] Garages [Ready] Garages May 22, 2018
@@ -114,6 +115,20 @@ class BaseModelInfo {
using ModelInfoTable =
std::unordered_map<ModelID, std::unique_ptr<BaseModelInfo>>;

static std::unordered_set<std::string> doorModels = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could think it would be const by default, as changing an unordered_set is not allowed (to my understanding). Weird.

// Create controller
std::unique_ptr<GarageController> garageController(
new GarageController(this, info, door));
garageControllers.push_back(std::move(garageController));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to create when "inserting". I think about push_back(std::make_unique(...)).

return false;
}

case GarageType::BombShop1:
Copy link

@ghost ghost May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add in "empty cases" break;.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not empty, it falls through

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is intentional?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Author

@ghost ghost May 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bombshops and resprays logic is different though, so this is incorrect anyway. But I was advised not to add more logic as there is a lot of code already.

@danhedron danhedron merged commit 2b096eb into rwengine:master May 24, 2018
@ghost ghost deleted the garages branch May 24, 2018 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants