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:
Opcode | Task |
---|---|
0x01 | Debt Repayment |
0x05 | Crime Investigation Result |
0x06 | Update Shipard Experience |
0x07 | Celebration |
0x0c | Land Transport Arrival |
0x15 | Marriage |
0x1a | Update Sailor Pools |
0x2e | Council Meeting |
0x35 | Unfreeze Harbor |
Related Functions
Address | Function | Description |
---|---|---|
0x004D8DD0 | reschedule_first_task | Moves the first element to its appropriate position in the queue. |