-
Notifications
You must be signed in to change notification settings - Fork 77
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
base: master
Are you sure you want to change the base?
Add leather addon #1720
Conversation
There was a problem hiding this 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
libs/s25main/Loader.cpp
Outdated
carrierEnum = fat ? leatheraddon::BobTypes::FAT_CARRIER_CARRYING_SKINS : | ||
leatheraddon::BobTypes::THIN_CARRIER_CARRYING_SKINS; | ||
|
||
if(ware == GoodType::Leather) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"})) |
There was a problem hiding this comment.
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?
libs/s25main/Loader.cpp
Outdated
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase version below too
There was a problem hiding this comment.
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 :)
libs/s25main/desktops/dskCredits.cpp
Outdated
@@ -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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
/// Der Arbeiter erzeugt eine Ware |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(job == Job::LeatherWorker) | |
else if(job == Job::LeatherWorker) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…ly died our died by the hunter)
…naturally died our died by the hunter) fix clang tidy
…s for coins - Order, upgrade, enable/disable - Add armor member to nofSoldier, reduce first armor before hitpoints
- refactor gui to handle adding new stuff more easily
…lding as for coins fix wrong logic c++ code
add missing comp code for new ham distribution category
temporary fix we clean this up later
@@ -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}); |
There was a problem hiding this comment.
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});
There was a problem hiding this comment.
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
libs/s25main/gameData/DoorConsts.h
Outdated
// 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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}, |
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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}, |
There was a problem hiding this comment.
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}
There was a problem hiding this comment.
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
Change different offsets and animations
…lding as for coins Invert upgrade order for armor. Now same as for gold
Use function for convertion and add invalid enum type
Refactor credits for more readable code
Fix clang tidy
Use enums for buttons and add buttons without offsets first
Fixes #1711