CleverRaven/Cataclysm-DDA — pull request #3173 by ianestrachan (2013-09-22 02:09:37+00:00)
Title: Refactoring of veh_interact [WIP]

Been working on this for a few days so it's pretty much guaranteed to cause conflicts. Putting this PR up now so I can tell how many and get some feedback before I merge master into the working branch and completely wreck the PR diff.

This long refactor was more-or-less required for my ultimate goal of removing the vpart_id enum and replacing it with a map<string, vpart_info>. This required figuring out the different uses of sel_part in veh_interact.cpp (sometimes it's referring to a vpart_info, sometimes it's a vehicle_part) and handling the fact that part installation goes through the player_activity object, which was only able to transfer ints around.

So, in short:

* General cleanup - removing dead code, unused variables, renaming variables to something that made sense and doesn't look like it came out of an obfuscator, bracing all braceable statements, and so on. Also converted some ints to more relevant types (vehicle_part pointers).
* The vpart_id enum is no more. vpart_list is now vehicle_part_types, a map<string, vpart_info> that uses ids from vehicle_parts.json. The upshot of this, my entire goal this whole time, is that **vehicle parts are now wholly defined in JSON, and can be added without needing to modify the code**. Since vehicles themselves have gotten the same treatment, new parts and vehicles can be added by touching only JSON. (This is good)
* The player_activity object now carries a vector<string> in addition to the vector<int> for passing string values around. However, its save_info and load_info can only handle strings without spaces in them (I tried and tried to do one value per line, but I kept getting segmentation faults, and it's not used anywhere else right now).
* The installation of lights now looks for items with the "LIGHT" flag, rather than specifically for the "headlight" ID.