eventhorizon5 / skyscraper

The Skyscraper Project (Skyscrapersim) - an open source building, city, and elevator simulator
https://www.skyscrapersim.net
GNU General Public License v2.0
28 stars 7 forks source link

Limit input length and do more error checking #30

Closed ghost closed 1 year ago

ghost commented 1 year ago

I saw controller.h define these two variables:

int bottom_floor; int top_floor;

These are practically unused throughout the whole program, so I utilized this to cap the input length. The function that defined those two variables however was a little broken, so I fixed it. So now for example, you can't enter an insanely high value like 999 into a keypad with a block of cars that only serve floors 1-10. This could be changed in the future if for some reason passcodes for accessing a service floor is implemented.

The keypad will also return ?? if inputs with symbols used improperly are added. The following should fail:

eventhorizon5 commented 1 year ago

I'll have to check this, because those top_floor and bottom_floor variables are now used. I did a really big merge earlier, which was the code that eliminates the original call button functionality and merges it all into the Dispatch Controller code, so the original call button handling code is no longer used. I've been doing cleanups with it, but the controller code is very different now since a lot of work was done.

eventhorizon5 commented 1 year ago

I merged the changes, it ended up only being changes in callstation.cpp.

For the top_floor and bottom_floor variables, those are private to prevent them from being changed by code outside of the controller, to access them you use the new GetTopFloor() and GetBottomFloor() functions, I changed your code so that it uses those.