20.11.2013, 13:29
Native hash maps, nice!
Though why do you need to send the address of [0][0]? What about finding that inside the init function?
BTW, it seems we think alike sometimes.
Edit: I just realized you can also make the array easy to deal with!
Abstract example:
Though why do you need to send the address of [0][0]? What about finding that inside the init function?
pawn Код:
// using varargs to avoid tag index mismatch
stock _HashMap_Init(other, things, size1, size2, ...) {
new addr;
#emit LOAD.S.pri 28 // 12+4*4
#emit MOVE.alt
#emit LOAD.I
#emit ADD
#emit STOR.S.pri addr
printf("address of arr[0][0]: %08x", addr);
}
_HashMap_Init(123, 456, sizeof(gArray), sizeof(gArray[]), gArray);
Edit: I just realized you can also make the array easy to deal with!
Abstract example:
pawn Код:
#include <a_samp>
enum E_DATA {
E_NAME[32],
E_OTHER1,
E_OTHER2
};
enum E_HASH_MAP_START {
E_NAME[32]
};
new g_EmptyArr[1][E_HASH_MAP_START];
stock func(arr[][E_HASH_MAP_START], size1, size2, ...) {
new addr;
#emit LOAD.S.pri 24
#emit STOR.S.pri 12 // override the address of arr
#emit MOVE.alt
#emit LOAD.I
#emit ADD
#emit LOAD.I
#emit STOR.S.pri addr
for (new i = 0; i < size1; i++) {
printf("%d: %s", i, arr[i][E_NAME]);
}
}
new g_Data[3][E_DATA] = {{"one", 1, 11}, {"two", 2, 22}, {"three", 3, 33}};
main() {
func(g_EmptyArr, sizeof(g_Data), sizeof(g_Data[]), g_Data);
}