[Ohrrpgce] SVN: james/8786 the cats() array is now almost always accessed via helper functions

James Paige Bob at hamsterrepublic.com
Thu Jun 1 07:50:36 PDT 2017


On Wed, May 31, 2017 at 9:27 PM, Ralph Versteegen <teeemcee at gmail.com>
wrote:

>
>
> On 1 June 2017 at 08:12, <subversion at hamsterrepublic.com> wrote:
>
>> james
>> 2017-05-31 13:12:35 -0700 (Wed, 31 May 2017)
>> 455
>> the cats() array is now almost always accessed via helper functions
>> herox() heroy() herox() and herodir()
>>
>> These are byref functions, so values can be assigned to them also.
>>
>> These functions take hero caterpillar rank as an argument,
>> eliminating all the many places where catx(n * 5) was accessed.
>>
>> Also added herotx() and heroty() that replace all the many times
>> when the x and y return values were immediately divided / 20 to get
>> hero tile x and tile y
>> ---
>> U   wip/game.bas
>> U   wip/game.bi
>> U   wip/game_udts.bi
>> U   wip/moresubs.rbas
>> U   wip/savegame.rbas
>> U   wip/scriptcommands.bas
>> U   wip/walkabouts.bas
>> U   wip/yetmore2.bas
>>
>
> Altogether, adding that bitset was quite a big project! A lot of helpful
> cleanup.
>
> This would be a good use for properties actually: turn
> hero{x,y,z,dir,tx,ty} into properties of herow. Then we will finally have a
> real hero walkabout UDT. (And can add XYpair versions, and allow assigning
> to tx/ty).
>

I had actually considered making these methods of herow() but herow is an
array of 4 HeroWalkabout objects, and (as far as I know) there is no way
for an array member to be aware of what element of the array it is in
(short of adding a .index member and keeping it updated whenever the array
changes)

I didn't want to be writing herow(i).x(i) all over the place,especially
since the first (i) in that would be effectively meaningless



> Also, the tx, ty accessors are a great idea. I feel like supporting larger
> tile sizes isn't going to be such a huge project.
>
>
Perhaps NPCInst could also use .tx() and .ty() helper methods that do the
same thing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20170601/d039c04a/attachment.htm>


More information about the Ohrrpgce mailing list