06-05-2013, 07:14 AM
Second iteration
The second iteration finally brings some functional code. To test that the actual protecting will work, the cStorage class is prototyped, with the loading function always returning one hard-coded area, (10,10) - (20,20). This way, we can focus on the actual act of protecting - handling the hooks so that the area cannot be touched by a player.
Also, it became clear that the PlayerAreas map needs to map player IDs to areas, instead of player names, because if a player connects with two clients (perfectly legal in MCS), their areas would get mixed with the name approach. With the ID approach, everything should work fine, each player will get their own instance of the cPlayerAreas class.
This version of the code has been tested to actually do something - now no player can interact with the blocks in the hard-coded area. Both block placing and block breaking are disabled. However, player's tools are still damaged when breaking blocks. This might be a bug in MCServer, and needs further examination later on.
The version attached to this post is also committed to the main MCS repository in rev 1557.
The second iteration finally brings some functional code. To test that the actual protecting will work, the cStorage class is prototyped, with the loading function always returning one hard-coded area, (10,10) - (20,20). This way, we can focus on the actual act of protecting - handling the hooks so that the area cannot be touched by a player.
Also, it became clear that the PlayerAreas map needs to map player IDs to areas, instead of player names, because if a player connects with two clients (perfectly legal in MCS), their areas would get mixed with the name approach. With the ID approach, everything should work fine, each player will get their own instance of the cPlayerAreas class.
This version of the code has been tested to actually do something - now no player can interact with the blocks in the hard-coded area. Both block placing and block breaking are disabled. However, player's tools are still damaged when breaking blocks. This might be a bug in MCServer, and needs further examination later on.
The version attached to this post is also committed to the main MCS repository in rev 1557.