summaryrefslogtreecommitdiffstats
path: root/src/control/Phones.h
blob: 02c9a9285fbbd34de95d7fd6d80fc9d87d486300 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once

#include "Physical.h"

class CPed;
class CAnimBlendAssociation;

enum PhoneState {
	PHONE_STATE_FREE,
	PHONE_STATE_REPORTING_CRIME, // CCivilianPed::ProcessControl sets it but unused
	PHONE_STATE_2,
	PHONE_STATE_MESSAGE_REMOVED,
	PHONE_STATE_ONETIME_MESSAGE_SET,
	PHONE_STATE_REPEATED_MESSAGE_SET,
	PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE,
	PHONE_STATE_ONETIME_MESSAGE_STARTED,
	PHONE_STATE_REPEATED_MESSAGE_STARTED,
	PHONE_STATE_9 // just rings, picking being handled via script. most of the time game uses this
};

class CPhone
{
public:
	CVector m_vecPos;
	wchar *m_apMessages[6];
	uint32 m_repeatedMessagePickupStart;
	CEntity *m_pEntity; // stored as building pool index in save files
	PhoneState m_nState;
	bool m_visibleToCam;

	CPhone() { }
	~CPhone() { }
};

VALIDATE_SIZE(CPhone, 0x34);

class CPhoneInfo {
public:
	static bool bDisplayingPhoneMessage;
	static uint32 PhoneEnableControlsTimer;
	static CPhone *pPhoneDisplayingMessages;
	static bool bPickingUpPhone;
	static CPed *pCallBackPed;

	int32 m_nMax;
	int32 m_nScriptPhonesMax;
	CPhone m_aPhones[NUMPHONES];

	CPhoneInfo() { }
	~CPhoneInfo() { }

	int FindNearestFreePhone(CVector*);
	bool PhoneAtThisPosition(CVector);
	bool HasMessageBeenDisplayed(int);
	bool IsMessageBeingDisplayed(int);
	void Load(uint8 *buf, uint32 size);
	void Save(uint8 *buf, uint32 *size);
	void SetPhoneMessage_JustOnce(int phoneId, wchar *msg1, wchar *msg2, wchar *msg3, wchar *msg4, wchar *msg5, wchar *msg6);
	void SetPhoneMessage_Repeatedly(int phoneId, wchar *msg1, wchar *msg2, wchar *msg3, wchar *msg4, wchar *msg5, wchar *msg6);
	int GrabPhone(float, float);
	void Initialise(void);
	void Shutdown(void);
	void Update(void);
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
	void SwapPhone(float xPos, float yPos, int into);
#endif
};

extern CPhoneInfo gPhoneInfo;

void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg);
void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg);

#ifdef PEDS_REPORT_CRIMES_ON_PHONE
extern CPed *crimeReporters[NUMPHONES];
bool isPhoneAvailable(int);
#endif