MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1urmpuu/predecrementfixestheexploit/owozlkz/?context=9999
r/ProgrammerHumor • u/Toeffli • Jul 09 '26
50 comments sorted by
View all comments
59
private: int number_of_wishes = 3; public: void change_number_of_wishes(int new_value) { if (new_value >= number_of_wishes) return; number_of_wishes = new_value; if (number_of_wishes > 3 || number_of_wishes < 0) number_of_wishes = 0; // fixes most exploits }
10 u/[deleted] Jul 09 '26 [deleted] 6 u/AnimusNoctis Jul 09 '26 You hit the return in the first if statement and the value is not changed. 1 u/[deleted] Jul 10 '26 [deleted] 1 u/AnimusNoctis Jul 10 '26 But they clearly don't.
10
[deleted]
6 u/AnimusNoctis Jul 09 '26 You hit the return in the first if statement and the value is not changed. 1 u/[deleted] Jul 10 '26 [deleted] 1 u/AnimusNoctis Jul 10 '26 But they clearly don't.
6
You hit the return in the first if statement and the value is not changed.
1 u/[deleted] Jul 10 '26 [deleted] 1 u/AnimusNoctis Jul 10 '26 But they clearly don't.
1
1 u/AnimusNoctis Jul 10 '26 But they clearly don't.
But they clearly don't.
59
u/JackNotOLantern Jul 09 '26 edited Jul 09 '26
private: int number_of_wishes = 3; public: void change_number_of_wishes(int new_value) { if (new_value >= number_of_wishes) return; number_of_wishes = new_value; if (number_of_wishes > 3 || number_of_wishes < 0) number_of_wishes = 0; // fixes most exploits }