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

Add leather addon #1720

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft

Conversation

ottml
Copy link
Contributor

@ottml ottml commented Dec 1, 2024

Fixes #1711

Copy link
Member

@Flamefire Flamefire left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I added some inline notes

carrierEnum = fat ? leatheraddon::BobTypes::FAT_CARRIER_CARRYING_SKINS :
leatheraddon::BobTypes::THIN_CARRIER_CARRYING_SKINS;

if(ware == GoodType::Leather)
Copy link
Member

Choose a reason for hiding this comment

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

Those should be else-ifs for better readability

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -512,6 +521,9 @@ bool Loader::LoadFilesAtGame(const std::string& mapGfxPath, bool isWinterGFX, co
if(!LoadResources({"wine_bobs"}))
return false;

if(!LoadResources({"leather_bobs"}))
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to condition those on the enabled addons? Feels wasteful but maybe the remaining code can't handle those to not be present?

The idea was also to integrate those with the "regular" files and have them be loaded automatically if the addon is enable (see the above TODO and initResourceFolders (addon argument)). Do you see any sensible archive for that?

@@ -907,6 +920,24 @@ void Loader::fillCaches()
wineaddon::bobIndex[fat ? wineaddon::BobTypes::FAT_CARRIER_CARRYING_WINE :
wineaddon::BobTypes::THIN_CARRIER_CARRYING_WINE]
+ static_cast<unsigned>(imgDir))));
} else if(leatheraddon::isLeatherAddonGoodType(ware))
{
leatheraddon::BobTypes carrierEnum;
Copy link
Member

Choose a reason for hiding this comment

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

Could this be an extra function (leather ware->leather bob index)? I'd also suggest an assertion as it currently isn't directly clear, that carrierEnum will always be initialized

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -102,6 +105,7 @@
/// 9: Drop serialization of node BQ
/// 10: troop_limits state introduced to military buildings
/// 11:: wineaddon added, three new building types and two new goods
/// 12:: leatheraddon added, three new building types and three new goods
Copy link
Member

Choose a reason for hiding this comment

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

Increase version below too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added compat code and increased version :)

@@ -358,7 +359,7 @@ void dskCredits::DrawCredit()
template<typename T>
T randEnum()
{
return T(rand() % (helpers::NumEnumValues_v<T> - 2));
return T(rand() % (helpers::NumEnumValues_v<T> - 5));
Copy link
Member

Choose a reason for hiding this comment

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

This looks odd (did before with the -2). Where does this magic number come from? Why does it apply to all random enum values generated? It is e.g. used for Job but then wine & leather is checked.for in line 404

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored the drawing code to be more clear and readable.

@@ -179,6 +182,15 @@ std::unique_ptr<noFigure> JobFactory::CreateJob(const Job job_id, const MapPoint
case Job::TempleServant:
RTTR_Assert(dynamic_cast<nobUsual*>(goal));
return std::make_unique<nofTempleServant>(pt, player, static_cast<nobUsual*>(goal));
case Job::Skinner:
RTTR_Assert(dynamic_cast<nobUsual*>(goal));
Copy link
Member

Choose a reason for hiding this comment

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

all that C&P...
Maybe a function for the assert-dynamic_cast-then-static_cast would be useful? Can't think of a good name though

void DrawWorking(DrawPoint drawPt) override;
/// Id in jobs.bob or carrier.bob when carrying a ware
[[noreturn]] unsigned short GetCarryID() const override;
/// Der Arbeiter erzeugt eine Ware
Copy link
Member

Choose a reason for hiding this comment

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

I'd not add any more German docstrings. Here it doesn't even add more information than the name of the function already does, so just remove

Suggested change
/// Der Arbeiter erzeugt eine Ware

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -91,7 +95,7 @@ iwBuildings::iwBuildings(GameWorldView& gwv, GameCommandFactory& gcFactory)

// "Help" button
Extent btSize = Extent(30, 32);
AddImageButton(35, GetFullSize() - DrawPoint(14, 20) - btSize, btSize, TextureColor::Grey,
AddImageButton(38, GetFullSize() - DrawPoint(14, 20) - btSize, btSize, TextureColor::Grey,
Copy link
Member

Choose a reason for hiding this comment

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

can you add a named constant for this (and possibly other) IDs? I.e. a file-scoped anonymous enum.
It might also be better to put all the building buttons last (with an offset) such that we don't need to "guess" the ID here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

leatheraddon::BobTypes type = leatheraddon::BobTypes::SKINNER_WALKING;
if(job == Job::Tanner)
type = leatheraddon::BobTypes::TANNER_WALKING;
if(job == Job::LeatherWorker)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if(job == Job::LeatherWorker)
else if(job == Job::LeatherWorker)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -352,6 +364,9 @@ const helpers::MultiEnumArray<SmokeConst, Nation, BuildingType> BUILDING_SMOKE_C
vikings[BuildingType::DonkeyBreeder] = SmokeConst(4, {-27, -40});
vikings[BuildingType::Vineyard] = SmokeConst(1, {18, -48});
vikings[BuildingType::Winery] = SmokeConst(1, {-14, -32});
vikings[BuildingType::Skinner] = SmokeConst(1, {7, -39});
Copy link

Choose a reason for hiding this comment

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

I made a typo with this one: it should be: vikings[BuildingType::Skinner] = SmokeConst(1, {-7, -39});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Use correct index for fat armor carrier 280 instead of 282, which is wrong in docu
…naturally died our died by the hunter)

Add check so skinner do not skinn the same animal, which leads to crash
// Römer
{4, 6, 8, 0, 12, 8, 16, 4, 0, -3, 8, 8, 8, 8, 6, 0, 10, 12, 14, 12,
9, 12, 12, 16, 19, 14, 16, 0, -8, 17, 0, 6, 9, 8, 14, 6, 4, -13, -8, 2},
{4, 6, 8, 11, 12, 8, 16, 4, 8, -3, 8, 8, 8, 8, 6, 12, 10, 12, 14, 12,
Copy link

Choose a reason for hiding this comment

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

So after some testing I think the Roman Leatherworks doorconst should be 8 not 12.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{{{0, 0}, {19, -4}, {19, -3}, {0, 0}, {23, -19}, {22, -7}, {-8, -10}, {9, -24}, {0, 0}, {29, -23},
{-2, -15}, {2, -13}, {-5, -16}, {-5, -15}, {0, 0}, {0, 0}, {0, 0}, {4, -16}, {9, -12}, {7, -10},
{{{0, 0}, {19, -4}, {19, -3}, {-14, -1}, {23, -19}, {22, -7}, {-8, -10}, {9, -24}, {-16, -10}, {29, -23},
{-2, -15}, {2, -13}, {-5, -16}, {-5, -15}, {0, 0}, {22, 6}, {0, 0}, {4, -16}, {9, -12}, {7, -10},
Copy link

Choose a reason for hiding this comment

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

I made another typo. African leatherworks X sign offset should be: {22,-6}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{{{0, 0}, {19, -6}, {19, -20}, {0, 0}, {5, -15}, {-32, -20}, {4, -16}, {10, -18}, {0, 0}, {20, -10},
{15, -10}, {15, -10}, {15, -10}, {15, -10}, {0, 0}, {0, 0}, {13, -5}, {-5, -13}, {15, -20}, {15, -1},
{{{0, 0}, {19, -6}, {19, -20}, {-7, -3}, {5, -15}, {-32, -20}, {4, -16}, {10, -18}, {3, -18}, {20, -10},
{15, -10}, {15, -10}, {15, -10}, {15, -10}, {0, 0}, {5, -4}, {13, -5}, {-5, -13}, {15, -20}, {15, -1},
Copy link

Choose a reason for hiding this comment

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

And Babylonian Leatherworks X sign should be: {15,-31}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

…lding as for coins

Use corretc x sign offsets
…lding as for coins

Invert upgrade order for armor. Now same as for gold
Use function for convertion and add invalid enum type
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.

New Addon: Leather Economy (new buildings/jobs/wares)
3 participants