Scheduled Tasks

P3 has a task queue for actions that shall be executed at a given tick in the future.

Scheduled Tasks Struct

00000000 struct scheduled_tasks // sizeof=0x14
00000000 {
00000000     scheduled_task *field_0_tasks;
00000004     int field_4_is_in_use;
00000008     unsigned __int16 field_8_earliest_scheduled_task_index;
0000000A     __int16 field_A;
0000000C     unsigned __int16 field_C_tasks_size;
0000000E     __int16 field_E;
00000010     int field_10;
00000014 };

The static scheduled tasks object is at 0x006DD73C. The handle_scheduled_tasks_tick function at 0x004D85C0 executes all tasks that are due. It is called at least once per tick.

Scheduled Task Struct

00000000 struct scheduled_task // sizeof=0x18
00000000 {
00000000     unsigned int field_0_due_timestamp;
00000004     unsigned __int16 field_4_next_task_index;
00000006     scheduled_task_opcode field_6_opcode;
00000008     scheduled_task_union field_8_data;
00000018 };

The scheduled task's opcdode field denotes which kind of task it is. Some task types are recurring, and reschedule themselves immediately when they are executed. The data field is a union containing all possible task arguments.

Identified Tasks

The following scheduled tasks have been identified:

OpcodeTask
0x01Debt Repayment
0x05Crime Investigation Result
0x06Update Shipard Experience
0x07Celebration
0x0cLand Transport Arrival
0x15Marriage
0x1aUpdate Sailor Pools
0x2eCouncil Meeting
0x35Unfreeze Harbor
AddressFunctionDescription
0x004D8DD0reschedule_first_taskMoves the first element to its appropriate position in the queue.