24.04.2015, 12:48
Hello, I thought of a phone system: player can have as many phones as he wants. Player can put the phone in his house, garage or in any vehicle. The thing is, even if he's not carrying it, the phone stays active(kind of).
Table design(maybe it will help to understand what am I trying to achieve)
The question
How to keep in memory? One large array for ALL phone data? Or at loading time I should load them into separate arrays for people, garages, vehicles and houses?
The first approach seems more elegant as I will be able to maintain all their data in one place.
The second obviously will be faster, no need to loop through the large array to find that phone.
Table design(maybe it will help to understand what am I trying to achieve)
Code:
CREATE TABLE IF NOT EXISTS phones ( number INT NOT NULL, online TINYINT NOT NULL DEFAULT '1', added_on DATETIME NOT NULL, location_type TINYINT NOT NULL, location_id INT NOT NULL, PRIMARY KEY(number), INDEX(location_type), INDEX(location_id) ) ENGINE=INNODB DEAFULT CHARSET=cp1257 COLLATE=cp1257_bin;
How to keep in memory? One large array for ALL phone data? Or at loading time I should load them into separate arrays for people, garages, vehicles and houses?
The first approach seems more elegant as I will be able to maintain all their data in one place.
The second obviously will be faster, no need to loop through the large array to find that phone.