Personally, I think "uid = npcCount + 1" followed by the increment is a little cleaner in some ways. What I mean is, in my mind at least, it's cleanest for counters of some event (such as IDs being assigned) to, as a rule, increment after the event rather than at any point prior to the event. Incrementing a counter just after is always possible for counters of an event, whereas incrementing prior is only possible in some cases, and always following the same convention when possible makes for more consistent code. I view the "uid =" line as the event being counted as that is the line that formally assigns the UID. In addition, "uid = npcCount + 1" also makes it very clear that the UIDs starting at 1 is intentional, whereas doing so by rearranging lines is a little less explicit that it was intentional unless you also add a comment to the code.Hoeloe wrote:That way it doesn't need to increment it twice. and still achieves the same effect.
EDIT: I would however be cool with the rearranging of lines you propose, if one also took the additional step of renaming "npcCount" to something like "lastestUID", because that would make the line where you increment it the line that formally assigns the next UID, rather than a counter of the number of UIDs that have been assigned.
Agreed. Last night had the thought that maybe I should give it a go some time, and the library ought to be quite a bit smaller when leveraging eventu and pnc. Lots of other things to be working on though, and a risk of accidentally creating subtle compatibility problems.Hoeloe wrote:Still, CinematX will hopefully be re-worked at some point in the future to make use of eventu and pnpc. I'd do it myself, but I don't really have to time to re-implement everything properly.