if (!day || !strcmp(day, "today")) {
sprintf(buf, "SQL: Reading object save for %s (#%ld)", ch->player.name, pid);
log(buf);
sprintf(buf, "SELECT * FROM PlayerStoredObjects WHERE PID=%ld", pid);
}
else {
sprintf(buf, "SQL: Reading backup object save for %s (#%ld), %s", ch->player.name, pid, day);
log(buf);
sprintf(buf, "SELECT * FROM BackupPlayerStoredObjects%s WHERE PID=%ld", day, pid);
}
begin transaction;
OLD_ID = select max(instance_id) from inventory;
insert into inventory select * from items where obj_id IN (select obj_id from corpse where corpse_id = CORPSE_BEING_LOOTED);
insert into players_inventories (player_id, instance_id) select (PLAYER_ID, instance_id) from inventory where instance_id > OLD_ID);
end transaction;
begin transaction;
update players_inventories set player_id = NEW_PLAYER_ID where player_id = OLD_PLAYER_ID and obj_id = OBJECT_BEING_TRADED;
update players set gold = gold - GOLD_TRADED where player_id = NEW_PLAYER_ID;
update players set gold = gold + GOLD_TRADED where player_id = OLD_PLAYER_ID;
end transaction;
call worldReplace('massice', 'massive');
If you stay at a hobbyist level, it may not worth it. A database is better for sure and I never said the contrary.
And as you said 'a database is better in the long run' long run is the keyword. 400 hours is alot of time, and to recoup them you will need to make an extensive use of your database.
It is like the time you would need to learn how to use awk/sed/bash compared than limit yourself to the tools provided by notepad++ to search/replace etc.
Let say you have one nail to plant and no hammer but a rock.
You could drive to the store get a hammer come back.
Using a rock you could have done it before you even started your engine.
All this depends on how frequent you have a nail to plant.
This is a better advice than 'you always have to get a hammer because it is a better tool for the job'. Yes it is…but no it is not always the best solution either. Especially in IT.
You can even check some of my post where I advocate the use of a database to someone instead of using flatfiles…on a NEW project.
Actually, when you start weighing database pros and cons, without ever mentioning the overhead for development, in a response to someone who has started a thread outlining what he has implemented it's a pretty clear indication that you're naysaying the necessity. And that's exactly what you did. You claimed the functionality databases offer for query is solved easier using bash and grep. That, sir, is using a tiny, tiny hammer for your screw.
You may say that NEW projects should use a database. Well, I say that people should use one on EXISTING projects. The right tool for the job didn't change just because you had the wrong tool handy. If you're going to be hacking at it for years, then spend the time and do things right. The entry level for putting stuff into a database isn't 400 hours. You could get everything moved over with no complex relationships in hours, not hundreds of hours. The OP obviously did a meticulous setup, which I applaud. But estimating 400 hours necessarily entry level for moving data into a database is about as absurd as 1 million billion hour. And I don't think he ever did that. The milage is going to vary based on A) your experience with the codebase in question B) your experience with the database technology and C) a lot of other things.