aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/viewer.h
blob: ed302ce9258da8e2fa547ab84f8cfbadf1875ba5 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/** 
 * @file viewer.h
 * @brief Main file for viewer.
 *
 * Copyright (c) 2000-2007, Linden Research, Inc.
 * 
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlife.com/developers/opensource/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at http://secondlife.com/developers/opensource/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 */

#ifndef LL_VIEWER_H
#define LL_VIEWER_H

#include "stdtypes.h"
#include "v3math.h"
#include "llcoord.h"

#include "lltimer.h"
#include "llframetimer.h"
#include "lluuid.h"
#include "llsys.h"
#include "lltransactiontypes.h"
#include "llviewercontrol.h"

// ************************************************************
// Enabled this definition to compile a 'hacked' viewer that
// allows a hacked godmode to be toggled on and off.
#define TOGGLE_HACKED_GODLIKE_VIEWER 

#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
extern BOOL gHackGodmode;
#endif
// ************************************************************

//
// Forward Declarations
//
class LLVector3d;
class LLViewerObject;
class LLMessageSystem;
class LLHost;
class LLAudioEngine;
class LLViewerRegion;
class LLVFS;
class LLGlobalEconomy;
class LLPieMenu;

//
// Global Variables
//

extern LLString gSecondLife;

extern S32 gNumSessions;
extern BOOL gNoRender;
extern LLMemoryInfo gSysMemory;
extern BOOL gLogMessages;
extern BOOL gLogUTC;
extern BOOL gUseAudio;
extern BOOL gConnectToSomething;
extern BOOL gGodConnect;
extern BOOL gRunLocal;
extern LLString gCmdLineFirstName;
extern LLString gCmdLineLastName;
extern LLString gCmdLinePassword;
extern BOOL gAutoLogin;
extern LLUUID gTemplateToken;
extern U32 gFrameCount;
extern BOOL gRequestInventoryLibrary;
extern BOOL gAcceptTOS;
extern BOOL gAcceptCriticalMessage;
extern LLUUID gInventoryLibraryOwner;
extern LLUUID gInventoryLibraryRoot;
extern BOOL gLastExecFroze;
extern F32 gLogoutMaxTime;
extern LLTimer gRenderStartTime;
extern LLTimer gLogoutTimer;
extern BOOL gInProductionGrid;
extern S32 gCrashBehavior;
extern bool gVerifySSLCert;


// TODO: Eliminate most of these, move into a globals structure.
extern const U32 PATCH_SIZE;
extern const LLVector3 DEFAULT_OBJECT_SCALE;
extern BOOL		gDisconnected;
extern BOOL		gQuit;						// We're done, quit after processing this message.
extern BOOL		gQuitRequested;				// User wants to quit, may have modified documents open.
extern BOOL		gLogoutRequestSent;			// Disconnect message sent to simulator, no longer safe to send messages to the sim.
extern BOOL		gInitializationComplete;	// OK to call display() and idle()
extern BOOL		gUseWireframe;
extern U32		gSecondsPerDay;
extern U32		gSecondsPerYear;
// Is the Pacific time zone (aka server time zone)
// currently in daylight savings time?
extern BOOL gPacificDaylightTime;

extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
extern F32		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
extern F32		gFPSClamped;						// Frames per second, smoothed, weighted toward last frame
extern F32		gFrameDTClamped;
extern U64		gStartTime;

extern LLFrameTimer	gRestoreGLTimer;
extern BOOL			gRestoreGL;

extern BOOL			gDisplayCameraPos;
extern BOOL			gDisplayWindInfo;
extern BOOL			gDisplayNearestWater;
extern BOOL			gDisplayFOV;
extern BOOL			gForceRenderLandFence;

extern BOOL			gAllowAFK;
extern BOOL			gShowObjectUpdates;

extern BOOL			gTeleportDisplay;
extern LLFrameTimer	gTeleportDisplayTimer;

extern LLGlobalEconomy *gGlobalEconomy;

// VFS globals - gVFS is for general use
// gStaticVFS is read-only and is shipped w/ the viewer
// it has pre-cache data like the UI .TGAs
extern LLVFS	*gStaticVFS;

extern LLUUID	gViewerDigest;  // MD5 digest of the viewer's executable file.

class LLURLSimString
{
public:
	enum { NOT_SET=0, NOT_PARSED=1, PARSE_OK=2, PARSE_FAIL=-1 };
	static void setString(const LLString& url);
	static bool parse();
	static bool unpack_data(void* data);
	static bool send_to_other_instance();
	
	LLURLSimString() : mX(128), mY(128), mZ(0), mParseState(NOT_PARSED) {}

private:
	static S32 parseGridIdx(const LLString& in_string, S32 idx0, S32* res, S32 max);
	struct llurl_data
	{
		char	mSimName[DB_SIM_NAME_BUF_SIZE];
		S32		mSimX;
		S32		mSimY;
		S32		mSimZ;
	};

	
public:
	static LLURLSimString sInstance;
	static LLString sLocationStringHome;
	static LLString sLocationStringLast;

public:
	LLString mSimString; // "name/x/y/z"
	LLString mSimName;
	S32 mX,mY,mZ;
	S32 mParseState;
};

extern LLUUID gSunTextureID;
extern LLUUID gMoonTextureID;

extern BOOL gHandleKeysAsync;

// Map scale in pixels per region
extern F32 gMapScale;
extern F32 gMiniMapScale;

extern F32 gMouseSensitivity;
extern BOOL gInvertMouse;

//
// Defines and constants
//

const S32 AGENT_UPDATES_PER_SECOND  = 10;

// Global because multiple functions need to identify the window
// by its name.
extern LLString gWindowTitle;
extern LLString gWindowName;
extern LLString gDisabledMessage;
extern BOOL gHideLinks;

#define REGIONS_PER_LANDSCAPE_EDGE  3 
#define NUMBER_OF_REGIONS	(REGIONS_PER_LANDSCAPE_EDGE 		\
							* REGIONS_PER_LANDSCAPE_EDGE)
#define CENTER_REGION		((REGIONS_PER_LANDSCAPE_EDGE / 2)	\
							* REGIONS_PER_LANDSCAPE_EDGE		\
							+ REGIONS_PER_LANDSCAPE_EDGE / 2)


// translates constant EAST, NORTH, WEST, etc. to x,y offsets
// eg, EAST = +1, 0
// eg, SOUTHWEST = -1, -1
const S32 MAP_REGION_TO_X[NUMBER_OF_REGIONS - 1] =
{
	1,	// east
	0,	// north
	-1,	// west
	0,	// south
	1,	// northeast
	-1,	// northwest
	-1,	// southwest
	1	// southeast
};
const S32 MAP_REGION_TO_Y[NUMBER_OF_REGIONS - 1] =
{
	0,	// east
	1,	// north
	0,	// west
	-1,	// south
	1,	// northeast
	1,	// northwest
	-1,	// southwest
	-1	// southeast
};

const BOOL FOR_SELECTION = TRUE;
const BOOL NOT_FOR_SELECTION = FALSE;

const U8 YES_PHYSICS = 1;
const U8 NO_PHYSICS = 0;

//
// Prototypes
//
void display(BOOL rebuild = TRUE, F32 zoom_factor = 1.f, int subfield = 0);
void draw_axes();

void fire_shot(const U8 shot_type, const U8 use_physics );
void add_object(LLPCode pcode, 
				U8 use_physics, 
				const LLVector3d &object_pos_global, 
				const LLQuaternion &rotation, 
				const LLVector3 &scale, 
				const LLVector3 &velocity,
				const LLVector3 &angular_velocity);

BOOL add_object(LLPCode pcode, S32 screen_x, S32 screen_y, U8 use_physics);

void idle();
void idle_network();
void init_audio();
void init_textures();
void init_landscape();
void keyboard(char key);
void keyboard_windows(char key);
void kill_all_trees();
void move_sun();
BOOL raycast_for_new_obj_pos( S32 x, S32 y, LLViewerObject** hit_obj, S32* hit_face, BOOL* b_hit_land, LLVector3* ray_start_region, LLVector3* ray_end_region, LLViewerRegion** region );

// Saves the final snapshot, but only once.
void save_final_snapshot(void*);

// Call when user is requesting application to quit.
void app_request_quit();

// Call when user aborts the quit, for example, canceling a required save of 
// dirty document.
void app_abort_quit();

// Call if you need to quit immediately.  You can optionally
// spawn a web page or open another application.
void app_force_quit(const char* launch_file_on_quit = NULL);

// Display an error dialog and forcibly quit.
void app_early_exit(const LLString& message);

// exit() immediately (after some cleanup)
void app_force_exit(S32 arg);

void do_disconnect(const LLString& message);
void send_logout_request();
void save_avatar(void*);

void set_view(S32 which);

void user_logout();

F32 mouse_x_from_center(S32 x);
F32 mouse_y_from_center(S32 x);

void print_agent_nvpairs(void*);
void reload_viewer(void);
void reset_statistics();
void output_statistics(void*);
void write_debug(const char *str);
void write_debug(const std::string& str);
void login_alert_done(S32 option, void* user_data);
void callback_cache_name(const LLUUID& id, const char* firstname, const char* lastname, BOOL is_group, void* data);
void load_name_cache();
void remove_marker_file();

// Avoid including llagent.h everywhere.  This returns gAgent.getID().
const LLUUID& agent_get_id();
const LLUUID& agent_get_session_id();
void agent_send_reliable_message();

// Helpers for URIs
const std::string& getLoginURI();
const std::string& getHelperURI();

#endif