2007-01-15 12:09:25 -08:00
/*
This file is part of Warzone 2100.
Copyright ( C ) 1999 - 2004 Eidos Interactive
2013-01-16 12:34:57 -08:00
Copyright ( C ) 2005 - 2013 Warzone 2100 Project
2007-01-15 12:09:25 -08:00
Warzone 2100 is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
Warzone 2100 is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with Warzone 2100 ; if not , write to the Free Software
Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA
*/
2008-02-16 05:05:34 -08:00
/**
* @ file display . c
2007-06-28 10:47:08 -07:00
*
* Display routines .
*
*/
2006-05-27 09:37:17 -07:00
# include "lib/framework/frame.h"
2006-09-23 10:24:55 -07:00
# include "lib/framework/input.h"
# include "lib/framework/strres.h"
2010-12-31 13:37:14 -08:00
# include "lib/ivis_opengl/piestate.h"
2013-02-18 11:39:25 -08:00
# include "lib/ivis_opengl/piedef.h"
2009-02-10 09:23:18 -08:00
# include "lib/framework/fixedpoint.h"
2011-12-11 15:07:02 -08:00
# include "lib/framework/wzapp.h"
2006-09-23 10:24:55 -07:00
2010-04-12 15:19:26 -07:00
# include "action.h"
2007-06-28 10:47:08 -07:00
# include "display.h"
# include "map.h"
# include "loop.h"
# include "component.h"
# include "display3d.h"
2008-03-30 06:23:11 -07:00
# include "lib/framework/cursors.h"
2007-06-28 10:47:08 -07:00
# include "hci.h"
# include "text.h"
# include "edit3d.h"
# include "geometry.h"
2006-05-27 09:37:17 -07:00
# include "lib/gamelib/gtime.h"
# include "lib/sound/audio.h"
2007-03-27 11:59:03 -07:00
# include "lib/sound/audio_id.h"
2007-06-28 10:47:08 -07:00
# include "radar.h"
# include "miscimd.h"
2009-02-10 09:23:09 -08:00
# include "lib/framework/math_ext.h"
2007-06-28 10:47:08 -07:00
# include "console.h"
# include "order.h"
# include "wrappers.h"
# include "power.h"
# include "map.h"
# include "keymap.h"
# include "intimage.h"
# include "mechanics.h"
2012-12-09 12:16:51 -08:00
# include "lighting.h"
2007-06-28 10:47:08 -07:00
# include "ingameop.h"
# include "oprint.h"
# include "warcam.h"
# include "keybind.h"
# include "keymap.h"
# include "projectile.h"
# include "message.h"
# include "effects.h"
2006-05-27 09:37:17 -07:00
# include "lib/script/script.h"
2007-06-28 10:47:08 -07:00
# include "scripttabs.h"
# include "scriptextern.h"
# include "scriptcb.h"
# include "drive.h"
# include "cmddroid.h"
# include "selection.h"
# include "transporter.h"
# include "intorder.h"
# include "multiplay.h"
2012-12-30 02:58:45 -08:00
# include "qtscript.h"
2008-03-30 08:44:50 -07:00
# include "warzoneconfig.h"
2007-06-28 10:47:08 -07:00
struct _dragBox dragBox3D , wallDrag ;
2012-02-25 16:21:29 -08:00
# define POSSIBLE_SELECTIONS 14
2007-06-28 10:47:08 -07:00
# define POSSIBLE_TARGETS 23
2009-04-26 14:35:32 -07:00
extern char DROIDDOING [ 512 ] ; // holds the string on what the droid is doing
2012-02-28 19:39:41 -08:00
// NOTE: the external file "cursorselection" is used, so you can import that into a spreadsheet, and edit it there, much easier.
2010-12-05 08:25:43 -08:00
static const CURSOR arnMPointers [ POSSIBLE_TARGETS ] [ POSSIBLE_SELECTIONS ] =
2007-06-28 10:47:08 -07:00
{
2012-02-28 19:39:41 -08:00
# include "cursorselection"
2007-06-28 10:47:08 -07:00
} ;
2007-12-17 12:32:17 -08:00
/// acceleration on scrolling. Game Option.
UDWORD scroll_speed_accel ;
2007-06-28 10:47:08 -07:00
2012-12-09 12:16:51 -08:00
/// Control zoom. Add an amount to zoom this much each second.
static float zoom_speed = 0.0f ;
static float zoom_target = 0.0f ;
2011-03-12 17:32:15 -08:00
static bool buildingDamaged ( STRUCTURE * psStructure ) ;
static bool repairDroidSelected ( UDWORD player ) ;
static bool vtolDroidSelected ( UDWORD player ) ;
static bool anyDroidSelected ( UDWORD player ) ;
static bool cyborgDroidSelected ( UDWORD player ) ;
static bool bInvertMouse = true ;
static bool bRightClickOrders = false ;
static bool bMiddleClickRotate = false ;
static bool bDrawShadows = true ;
2007-11-20 14:18:17 -08:00
static SELECTION_TYPE establishSelection ( UDWORD selectedPlayer ) ;
static void dealWithLMB ( void ) ;
static void dealWithLMBDClick ( void ) ;
static void dealWithRMB ( void ) ;
2011-03-12 17:32:15 -08:00
static bool mouseInBox ( SDWORD x0 , SDWORD y0 , SDWORD x1 , SDWORD y1 ) ;
2007-11-20 14:18:17 -08:00
static OBJECT_POSITION * checkMouseLoc ( void ) ;
2012-06-21 15:34:04 -07:00
void finishDeliveryPosition ( void ) ;
2011-03-12 17:32:15 -08:00
static bool bInstantRadarJump = false ;
2007-11-20 14:18:17 -08:00
static SDWORD desiredPitch = 340 ;
static UDWORD currentFrame ;
2007-06-28 10:47:08 -07:00
static UDWORD StartOfLastFrame ;
2007-11-20 14:18:17 -08:00
static SDWORD rotX ;
static SDWORD rotY ;
static UDWORD rotInitial ;
static UDWORD rotInitialUp ;
static UDWORD xMoved , yMoved ;
static STRUCTURE * psBuilding ;
2011-03-12 17:32:15 -08:00
static bool edgeOfMap = false ;
2010-12-08 18:34:54 -08:00
static uint32_t scrollRefTime ;
2007-11-20 14:18:17 -08:00
static float scrollSpeedLeftRight ; //use two directions and add them because its simple
static float scrollStepLeftRight ;
static float scrollSpeedUpDown ;
static float scrollStepUpDown ;
2011-03-12 17:32:15 -08:00
static bool mouseOverRadar = false ;
static bool mouseOverConsole = false ;
static bool ignoreOrder = false ;
static bool ignoreRMBC = true ;
2007-11-20 14:18:17 -08:00
static DROID * psSelectedVtol ;
static DROID * psDominantSelected ;
2011-03-12 17:32:15 -08:00
static bool bRadarDragging = false ;
2010-01-23 19:39:44 -08:00
static bool mouseScroll = true ;
2012-12-30 04:24:12 -08:00
static UDWORD CurrentItemUnderMouse = 0 ;
2007-11-20 14:18:17 -08:00
2011-03-12 17:32:15 -08:00
bool rotActive = false ;
bool gameStats = false ;
2007-06-28 10:47:08 -07:00
/* Hackety hack hack hack */
2012-12-30 04:24:12 -08:00
static int screenShakeTable [ 100 ] =
2007-06-28 10:47:08 -07:00
{
- 2 , - 2 , - 3 , - 4 , - 3 , - 3 , - 5 , - 4 , - 4 , - 4 ,
- 4 , - 5 , - 5 , - 5 , - 5 , - 7 , - 5 , - 6 , - 8 , - 6 ,
- 7 , - 8 , - 6 , - 4 , - 8 , - 7 , - 7 , - 7 , - 6 , - 5 ,
- 6 , - 5 , - 2 , - 5 , - 6 , - 3 , - 5 , - 3 , - 2 , - 4 ,
- 5 , - 3 , - 2 , - 0 , 1 , 2 , 2 , 1 , 0 , 0 ,
0 , 1 , 1 , 3 , 2 , 1 , 0 , 2 , 3 , 4 ,
4 , 2 , 6 , 4 , 5 , 3 , 7 , 7 , 3 , 6 ,
4 , 7 , 9 , 10 , 9 , 8 , 6 , 4 , 7 , 5 ,
5 , 4 , 6 , 2 , 4 , 5 , 3 , 3 , 2 , 1 ,
1 , 0 , - 1 , - 1 , - 2 , - 1 , 1 , 0 , 1 , 0
} ;
2011-03-12 17:32:15 -08:00
static bool bScreenShakeActive = false ;
2007-06-28 10:47:08 -07:00
static UDWORD screenShakeStarted ;
static UDWORD screenShakeLength ;
//used to determine is a weapon droid is assigned to a sensor tower or sensor droid
2011-03-12 17:32:15 -08:00
static bool bSensorAssigned ;
2007-06-28 10:47:08 -07:00
//used to determine if the player has selected a Las Sat structure
2011-03-12 17:32:15 -08:00
static bool bLasSatStruct ;
2007-06-28 10:47:08 -07:00
// Local prototypes
static MOUSE_TARGET itemUnderMouse ( BASE_OBJECT * * ppObjUnderCursor ) ;
2011-03-12 17:32:15 -08:00
static bool bShakingPermitted = true ;
2007-11-20 14:18:17 -08:00
2012-12-09 12:16:51 -08:00
float getZoom ( )
{
return zoom_target ;
}
float getZoomSpeed ( )
{
return fabsf ( zoom_speed ) ;
}
void setZoom ( float zoomSpeed , float zoomTarget )
{
float zoom_origin = getViewDistance ( ) ;
zoom_speed = zoomSpeed ;
zoom_target = zoomTarget ;
zoom_speed * = zoom_target > zoom_origin ? 1 : - 1 ; // get direction
}
void zoom ( )
{
if ( zoom_speed ! = 0.0f )
{
float distance = getViewDistance ( ) ;
distance + = graphicsTimeAdjustedIncrement ( zoom_speed ) ;
if ( ( zoom_speed > 0.0f & & distance > zoom_target ) | | ( zoom_speed < = 0.0f & & distance < zoom_target ) )
{
distance = zoom_target ; // reached target
zoom_speed = 0.0f ;
}
setViewDistance ( distance ) ;
UpdateFogDistance ( distance ) ;
}
}
2012-03-13 16:23:08 -07:00
bool isMouseOverRadar ( )
{
return mouseOverRadar ;
}
2010-01-23 19:39:44 -08:00
void setMouseScroll ( bool scroll )
{
mouseScroll = scroll ;
}
2007-06-28 10:47:08 -07:00
2011-03-12 17:32:15 -08:00
void setRadarJump ( bool val )
2007-06-28 10:47:08 -07:00
{
bInstantRadarJump = val ;
}
2011-03-12 17:32:15 -08:00
bool getRadarJumpStatus ( void )
2007-06-28 10:47:08 -07:00
{
return ( bInstantRadarJump ) ;
}
2011-03-12 17:32:15 -08:00
bool getShakeStatus ( void )
2007-06-28 10:47:08 -07:00
{
return ( bShakingPermitted ) ;
}
2011-03-12 17:32:15 -08:00
bool getInvertMouseStatus ( void )
2007-06-28 10:47:08 -07:00
{
return ( bInvertMouse ) ;
}
2011-03-12 17:32:15 -08:00
void setInvertMouseStatus ( bool val )
2007-06-28 10:47:08 -07:00
{
bInvertMouse = val ;
}
2009-03-12 02:25:29 -07:00
# define MOUSE_ORDER (bRightClickOrders?MOUSE_RMB:MOUSE_LMB)
# define MOUSE_SELECT (bRightClickOrders?MOUSE_LMB:MOUSE_RMB)
2010-07-15 18:26:34 -07:00
# define MOUSE_ROTATE (bMiddleClickRotate?MOUSE_MMB:MOUSE_RMB)
2009-03-12 02:25:29 -07:00
2011-03-12 17:32:15 -08:00
bool getRightClickOrders ( void )
2009-03-12 02:25:29 -07:00
{
return bRightClickOrders ;
}
2011-03-12 17:32:15 -08:00
void setRightClickOrders ( bool val )
2009-03-12 02:25:29 -07:00
{
bRightClickOrders = val ;
}
2011-03-12 17:32:15 -08:00
bool getMiddleClickRotate ( void )
2010-07-15 18:26:34 -07:00
{
return bMiddleClickRotate ;
}
2011-03-12 17:32:15 -08:00
void setMiddleClickRotate ( bool val )
2010-07-15 18:26:34 -07:00
{
bMiddleClickRotate = val ;
}
2011-03-12 17:32:15 -08:00
bool getDrawShadows ( void )
2006-02-28 06:04:59 -08:00
{
return ( bDrawShadows ) ;
}
2011-03-12 17:32:15 -08:00
void setDrawShadows ( bool val )
2006-02-28 06:04:59 -08:00
{
bDrawShadows = val ;
2013-02-18 11:39:25 -08:00
pie_setShadows ( val ) ;
2006-02-28 06:04:59 -08:00
}
2011-03-12 17:32:15 -08:00
void setShakeStatus ( bool val )
2007-06-28 10:47:08 -07:00
{
bShakingPermitted = val ;
}
2012-03-30 16:22:43 -07:00
void shakeStart ( unsigned int length )
2007-06-28 10:47:08 -07:00
{
if ( bShakingPermitted )
{
if ( ! bScreenShakeActive )
{
2008-03-24 09:51:17 -07:00
bScreenShakeActive = true ;
2007-06-28 10:47:08 -07:00
screenShakeStarted = gameTime ;
2012-03-30 16:22:43 -07:00
screenShakeLength = length ;
2007-06-28 10:47:08 -07:00
}
}
}
void shakeStop ( void )
{
2008-03-24 09:51:17 -07:00
bScreenShakeActive = false ;
2007-06-28 10:47:08 -07:00
player . r . z = 0 ;
}
2006-09-20 08:18:37 -07:00
static void shakeUpdate ( void )
2007-06-28 10:47:08 -07:00
{
UDWORD screenShakePercentage ;
/* Check if we're shaking the screen or not */
2012-03-30 16:22:43 -07:00
if ( bScreenShakeActive )
2007-06-28 10:47:08 -07:00
{
2012-03-30 16:22:43 -07:00
screenShakePercentage = PERCENT ( gameTime - screenShakeStarted , screenShakeLength ) ;
if ( screenShakePercentage < 100 )
2007-06-28 10:47:08 -07:00
{
player . r . z = 0 + DEG ( screenShakeTable [ screenShakePercentage ] ) ;
}
2012-03-30 16:22:43 -07:00
if ( gameTime > ( screenShakeStarted + screenShakeLength ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
bScreenShakeActive = false ;
2007-06-28 10:47:08 -07:00
player . r . z = 0 ;
}
}
else
{
2012-03-30 16:22:43 -07:00
if ( ! getWarCamStatus ( ) )
2007-06-28 10:47:08 -07:00
{
player . r . z = 0 ;
}
}
}
2012-03-13 16:23:08 -07:00
void ProcessRadarInput ( )
2007-06-28 10:47:08 -07:00
{
2008-08-02 08:17:22 -07:00
int PosX , PosY ;
2007-06-28 10:47:08 -07:00
int x = mouseX ( ) ;
int y = mouseY ( ) ;
UDWORD temp1 , temp2 ;
/* Only allow jump-to-area-of-map if radar is on-screen */
2008-03-24 09:51:17 -07:00
mouseOverRadar = false ;
2012-01-14 10:39:54 -08:00
if ( radarOnScreen & & radarPermitted )
2007-06-28 10:47:08 -07:00
{
2006-05-27 09:37:17 -07:00
if ( CoordInRadar ( x , y ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
mouseOverRadar = true ;
2007-06-28 10:47:08 -07:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( mousePressed ( MOUSE_ORDER ) | | ( mousePressed ( MOUSE_MMB ) & & keyDown ( KEY_LALT ) ) )
2007-05-29 19:06:46 -07:00
{
2010-12-15 06:38:16 -08:00
if ( mousePressed ( MOUSE_ORDER ) )
{
2013-01-26 08:48:54 -08:00
x = mousePressPos_DEPRECATED ( MOUSE_ORDER ) . x ;
y = mousePressPos_DEPRECATED ( MOUSE_ORDER ) . y ;
2010-12-15 06:38:16 -08:00
}
else
{
2013-01-26 08:48:54 -08:00
x = mousePressPos_DEPRECATED ( MOUSE_MMB ) . x ;
y = mousePressPos_DEPRECATED ( MOUSE_MMB ) . y ;
2010-12-15 06:38:16 -08:00
}
2007-06-28 10:47:08 -07:00
if ( driveModeActive ( ) ) {
driveProcessRadarInput ( x , y ) ;
} else {
2006-05-27 09:37:17 -07:00
2007-06-28 10:47:08 -07:00
/* If we're tracking a droid, then cancel that */
2008-08-02 08:17:22 -07:00
CalcRadarPosition ( x , y , & PosX , & PosY ) ;
2007-06-28 10:47:08 -07:00
if ( mouseOverRadar )
{
// MARKER
// Send all droids to that location
orderSelectedLoc ( selectedPlayer , ( PosX * TILE_UNITS ) + TILE_UNITS / 2 ,
2010-01-20 10:08:46 -08:00
( PosY * TILE_UNITS ) + TILE_UNITS / 2 , ctrlShiftDown ( ) ) ; // ctrlShiftDown() = ctrl clicked a destination, add an order
2007-06-28 10:47:08 -07:00
2006-05-27 09:37:17 -07:00
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
CheckScrollLimits ( ) ;
audio_PlayTrack ( ID_SOUND_MESSAGEEND ) ;
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
}
2007-06-28 10:47:08 -07:00
2009-03-12 02:25:29 -07:00
if ( mouseDrag ( MOUSE_SELECT , & temp1 , & temp2 ) & & ! rotActive )
2007-06-28 10:47:08 -07:00
{
2008-08-02 08:17:22 -07:00
CalcRadarPosition ( x , y , & PosX , & PosY ) ;
2008-03-24 09:51:17 -07:00
setViewPos ( PosX , PosY , true ) ;
bRadarDragging = true ;
2009-04-10 17:38:28 -07:00
if ( ctrlShiftDown ( ) )
2007-06-28 10:47:08 -07:00
{
player . r . y = 0 ;
}
}
2009-03-12 02:25:29 -07:00
else if ( mousePressed ( MOUSE_SELECT ) )
2007-05-29 19:06:46 -07:00
{
2013-01-26 08:48:54 -08:00
x = mousePressPos_DEPRECATED ( MOUSE_SELECT ) . x ;
y = mousePressPos_DEPRECATED ( MOUSE_SELECT ) . y ;
2010-12-15 06:38:16 -08:00
2008-08-02 08:17:22 -07:00
CalcRadarPosition ( x , y , & PosX , & PosY ) ;
2007-06-28 10:47:08 -07:00
if ( bInstantRadarJump )
{
/* Go instantly */
2008-03-24 09:51:17 -07:00
setViewPos ( PosX , PosY , true ) ;
2007-06-28 10:47:08 -07:00
}
else
{
/* Pan to it */
requestRadarTrack ( PosX * TILE_UNITS , PosY * TILE_UNITS ) ;
}
2007-05-29 19:06:46 -07:00
}
2012-03-13 07:24:17 -07:00
// ctrl-alt-scroll changes game speed
if ( ! keyDown ( KEY_LCTRL ) | | ! keyDown ( KEY_LALT ) )
{
if ( mousePressed ( MOUSE_WUP ) )
{
kf_RadarZoomIn ( ) ;
}
else if ( mousePressed ( MOUSE_WDN ) )
{
kf_RadarZoomOut ( ) ;
}
}
2007-05-29 19:06:46 -07:00
}
2007-06-28 10:47:08 -07:00
}
}
// reset the input state
void resetInput ( void )
{
2008-03-24 09:51:17 -07:00
rotActive = false ;
2007-06-28 10:47:08 -07:00
dragBox3D . status = DRAG_INACTIVE ;
wallDrag . status = DRAG_INACTIVE ;
}
/* Process the user input. This just processes the key input and jumping around the radar*/
void processInput ( void )
{
2011-03-12 17:32:15 -08:00
bool mOverConstruction = false ;
2010-10-20 21:55:55 -07:00
2010-09-01 19:53:13 -07:00
if ( InGameOpUp | | isInGamePopupUp )
{
dragBox3D . status = DRAG_RELEASED ; // disengage the dragging since it stops menu input
}
2010-10-20 21:55:55 -07:00
if ( CoordInBuild ( mouseX ( ) , mouseY ( ) ) )
{
mOverConstruction = true ;
}
2007-05-29 19:06:46 -07:00
StartOfLastFrame = currentFrame ;
currentFrame = frameGetFrameNumber ( ) ;
2007-06-28 10:47:08 -07:00
psBuilding = NULL ;
2008-03-24 09:51:17 -07:00
edgeOfMap = false ;
2006-05-27 09:37:17 -07:00
2008-03-24 09:51:17 -07:00
ignoreRMBC = false ;
2007-06-28 10:47:08 -07:00
/* Process all of our key mappings */
2012-03-13 16:23:08 -07:00
if ( mousePressed ( MOUSE_WUP ) & & ! isMouseOverRadar ( ) )
2007-06-28 10:47:08 -07:00
{
2010-01-12 20:10:00 -08:00
/* Ctrl+Alt+WheelUp makes game speed up */
if ( keyDown ( KEY_LCTRL ) & & keyDown ( KEY_LALT ) )
2006-08-30 10:02:58 -07:00
{
kf_SpeedUp ( ) ;
}
2010-10-20 21:55:55 -07:00
else if ( mOverConstruction )
{
kf_BuildPrevPage ( ) ;
}
2006-08-30 10:02:58 -07:00
else
{
2010-12-29 15:46:06 -08:00
kf_ZoomInStep ( ) ;
2006-08-30 10:02:58 -07:00
}
2007-06-28 10:47:08 -07:00
}
2012-03-13 16:23:08 -07:00
if ( mousePressed ( MOUSE_WDN ) & & ! isMouseOverRadar ( ) )
2007-06-28 10:47:08 -07:00
{
2010-01-12 20:10:00 -08:00
/* Ctrl+Alt+WheelDown makes game slow down */
if ( keyDown ( KEY_LCTRL ) & & keyDown ( KEY_LALT ) )
2006-08-30 10:02:58 -07:00
{
kf_SlowDown ( ) ;
}
2010-10-20 21:55:55 -07:00
else if ( mOverConstruction )
{
kf_BuildNextPage ( ) ;
}
2007-06-28 10:47:08 -07:00
else
{
2010-12-29 15:46:06 -08:00
kf_ZoomOutStep ( ) ;
2007-06-28 10:47:08 -07:00
}
}
2007-05-29 19:06:46 -07:00
if ( intMode = = INT_DESIGN )
2007-06-28 10:47:08 -07:00
{
/* Only process the function keys */
2008-03-24 09:51:17 -07:00
keyProcessMappings ( true ) ;
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
else if ( bAllowOtherKeyPresses )
{
/* Run all standard mappings */
2008-03-24 09:51:17 -07:00
keyProcessMappings ( false ) ;
2007-05-29 19:06:46 -07:00
}
else
{
kf_SendTextMessage ( ) ; // process multiplayer chat message.
}
2007-06-28 10:47:08 -07:00
/* Allow the user to clear the console if need be */
mouseOverConsole = mouseOverConsoleBox ( ) ;
2007-02-10 08:39:39 -08:00
if ( mouseOverConsole & & mousePressed ( MOUSE_LMB ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
setConsolePermanence ( false , true ) ;
2007-06-28 10:47:08 -07:00
}
}
2011-03-12 17:32:15 -08:00
static bool OverRadarAndNotDragging ( void )
2007-06-28 10:47:08 -07:00
{
2012-01-14 10:39:54 -08:00
return mouseOverRadar & & dragBox3D . status ! = DRAG_DRAGGING & & radarPermitted & & wallDrag . status ! = DRAG_DRAGGING ;
2007-06-28 10:47:08 -07:00
}
2006-09-14 06:15:40 -07:00
static void CheckFinishedDrag ( void )
2007-06-28 10:47:08 -07:00
{
if ( driveModeActive ( ) ) {
return ;
}
2010-07-15 18:26:34 -07:00
if ( mouseReleased ( MOUSE_LMB ) | | mouseDown ( MOUSE_RMB ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
selectAttempt = false ;
2007-06-28 10:47:08 -07:00
if ( dragBox3D . status = = DRAG_DRAGGING )
{
2007-05-29 19:06:46 -07:00
if ( wallDrag . status = = DRAG_DRAGGING )
{
//if invalid location keep looking for a valid one
2008-02-10 10:21:02 -08:00
if ( ( buildState = = BUILD3D_VALID | | buildState = = BUILD3D_FINISHED )
& & sBuildDetails . psStats - > ref > = REF_STRUCTURE_START
& & sBuildDetails . psStats - > ref < ( REF_STRUCTURE_START + REF_RANGE ) )
2007-05-29 19:06:46 -07:00
{
2007-05-30 11:03:26 -07:00
if ( ( ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_WALL
2009-06-04 10:22:20 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_DEFENSE
2010-02-18 11:35:37 -08:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_GATE
2009-06-04 10:22:20 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_REARM_PAD )
2007-05-30 11:03:26 -07:00
& & ! isLasSat ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) )
2007-05-29 19:06:46 -07:00
{
wallDrag . x2 = mouseTileX ;
wallDrag . y2 = mouseTileY ;
wallDrag . status = DRAG_RELEASED ;
}
}
}
2007-06-28 10:47:08 -07:00
/* Only clear if shift isn't down - this is for the drag selection box for units*/
2009-04-10 17:38:28 -07:00
if ( ! ctrlShiftDown ( ) & & wallDrag . status = = DRAG_INACTIVE )
2007-06-28 10:47:08 -07:00
{
clearSelection ( ) ;
}
2007-05-29 19:06:46 -07:00
dragBox3D . status = DRAG_RELEASED ;
2010-03-10 04:31:27 -08:00
dragBox3D . x2 = mouseX ( ) ;
dragBox3D . y2 = mouseY ( ) ;
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
else
2007-06-28 10:47:08 -07:00
{
dragBox3D . status = DRAG_INACTIVE ;
wallDrag . status = DRAG_INACTIVE ;
}
}
}
2006-09-14 06:15:40 -07:00
static void CheckStartWallDrag ( void )
2007-06-28 10:47:08 -07:00
{
if ( driveModeActive ( ) ) {
return ;
}
if ( mousePressed ( MOUSE_LMB ) )
{
/* Store away the details if we're building */
// You can start dragging walls from invalid locations so check for
// BUILD3D_POS or BUILD3D_VALID, used tojust check for BUILD3D_VALID.
2008-02-10 10:21:02 -08:00
if ( ( buildState = = BUILD3D_POS | | buildState = = BUILD3D_VALID )
& & sBuildDetails . psStats - > ref > = REF_STRUCTURE_START
& & sBuildDetails . psStats - > ref < ( REF_STRUCTURE_START + REF_RANGE ) )
2007-06-28 10:47:08 -07:00
{
2007-05-30 11:03:26 -07:00
if ( ( ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_WALL
2009-06-04 10:22:20 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_DEFENSE
2010-02-18 11:35:37 -08:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_GATE
2009-06-04 10:22:20 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_REARM_PAD )
2007-05-30 11:03:26 -07:00
& & ! isLasSat ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) )
2007-06-28 10:47:08 -07:00
{
wallDrag . x1 = wallDrag . x2 = mouseTileX ;
wallDrag . y1 = wallDrag . y2 = mouseTileY ;
wallDrag . status = DRAG_PLACING ;
2006-08-22 07:28:49 -07:00
debug ( LOG_NEVER , " Start Wall Drag \n " ) ;
2007-06-28 10:47:08 -07:00
}
}
else if ( intBuildSelectMode ( ) ) //if we were in build select mode
{
//uhoh no place to build here
audio_PlayTrack ( ID_SOUND_BUILD_FAIL ) ;
}
}
}
//this function is called when a location has been chosen to place a structure or a DP
2011-03-12 17:32:15 -08:00
static bool CheckFinishedFindPosition ( void )
2007-06-28 10:47:08 -07:00
{
2011-03-12 17:32:15 -08:00
bool OverRadar = OverRadarAndNotDragging ( ) ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
/* Do not let the player position buildings 'under' the radar */
if ( mouseReleased ( MOUSE_LMB ) & & ! OverRadar )
{
2012-06-21 15:34:04 -07:00
if ( deliveryReposValid ( ) )
{
finishDeliveryPosition ( ) ;
return true ;
}
else if ( buildState = = BUILD3D_VALID )
2007-06-28 10:47:08 -07:00
{
2007-05-30 11:03:26 -07:00
if ( ( ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_WALL
2010-02-18 11:35:37 -08:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_GATE
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_REARM_PAD
2007-05-30 11:03:26 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_DEFENSE )
2008-02-10 10:21:02 -08:00
& & sBuildDetails . psStats - > ref > = REF_STRUCTURE_START
& & sBuildDetails . psStats - > ref < ( REF_STRUCTURE_START + REF_RANGE )
2007-05-30 11:03:26 -07:00
& & ! isLasSat ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) )
2007-06-28 10:47:08 -07:00
{
2007-05-29 19:06:46 -07:00
int dx , dy ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
wallDrag . x2 = mouseTileX ;
wallDrag . y2 = mouseTileY ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
dx = abs ( mouseTileX - wallDrag . x1 ) ;
dy = abs ( mouseTileY - wallDrag . y1 ) ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
if ( dx > = dy ) {
wallDrag . y2 = wallDrag . y1 ;
} else if ( dx < dy ) {
wallDrag . x2 = wallDrag . x1 ;
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
wallDrag . status = DRAG_RELEASED ;
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
debug ( LOG_NEVER , " BUILD3D_FINISHED \n " ) ;
buildState = BUILD3D_FINISHED ;
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
2007-05-29 19:06:46 -07:00
}
2007-06-28 10:47:08 -07:00
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
2006-09-14 06:15:40 -07:00
static void HandleDrag ( void )
2007-06-28 10:47:08 -07:00
{
2007-05-29 19:06:46 -07:00
UDWORD dragX , dragY ;
2007-06-28 10:47:08 -07:00
2007-12-18 13:11:04 -08:00
if ( ( driveModeActive ( ) & & mouseDown ( MOUSE_LMB ) )
| | ( mouseDrag ( MOUSE_LMB , & dragX , & dragY ) & & ! mouseOverRadar & & ! mouseDown ( MOUSE_RMB ) ) )
2007-06-28 10:47:08 -07:00
{
2007-12-18 13:11:04 -08:00
if ( ! driveModeActive ( ) ) {
dragBox3D . x1 = dragX ;
2010-03-10 04:31:27 -08:00
dragBox3D . x2 = mouseX ( ) ;
2007-12-18 13:11:04 -08:00
dragBox3D . y1 = dragY ;
2010-03-10 04:31:27 -08:00
dragBox3D . y2 = mouseY ( ) ;
2007-12-24 05:57:19 -08:00
2007-12-18 13:11:04 -08:00
dragBox3D . status = DRAG_DRAGGING ;
}
2007-06-28 10:47:08 -07:00
if ( buildState = = BUILD3D_VALID )
{
2007-05-30 11:03:26 -07:00
if ( ( ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_WALL
2010-02-18 11:35:37 -08:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_GATE
2009-06-04 10:22:20 -07:00
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_DEFENSE
| | ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) - > type = = REF_REARM_PAD )
2007-05-30 11:03:26 -07:00
& & ! isLasSat ( ( STRUCTURE_STATS * ) sBuildDetails . psStats ) )
2007-06-28 10:47:08 -07:00
{
2007-05-29 19:06:46 -07:00
int dx , dy ;
2007-06-28 10:47:08 -07:00
wallDrag . x2 = mouseTileX ;
wallDrag . y2 = mouseTileY ;
dx = abs ( mouseTileX - wallDrag . x1 ) ;
dy = abs ( mouseTileY - wallDrag . y1 ) ;
if ( dx > = dy ) {
wallDrag . y2 = wallDrag . y1 ;
} else if ( dx < dy ) {
wallDrag . x2 = wallDrag . x1 ;
}
wallDrag . status = DRAG_DRAGGING ;
}
}
}
}
UDWORD getTargetType ( void )
{
return CurrentItemUnderMouse ;
}
//don't want to do any of these whilst in the Intelligence Screen
void processMouseClickInput ( void )
{
UDWORD i ;
SELECTION_TYPE selection ;
MOUSE_TARGET item = MT_NOTARGET ;
2011-03-12 17:32:15 -08:00
bool OverRadar = OverRadarAndNotDragging ( ) ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
ignoreOrder = CheckFinishedFindPosition ( ) ;
2007-06-28 10:47:08 -07:00
CheckStartWallDrag ( ) ;
HandleDrag ( ) ;
CheckFinishedDrag ( ) ;
2007-11-20 14:18:17 -08:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( ( mouseReleased ( MOUSE_LMB ) | | ( mouseReleased ( MOUSE_MMB ) & & ( keyDown ( KEY_LALT ) | | keyDown ( KEY_RALT ) ) ) ) & & ! OverRadar & &
2007-02-10 08:39:39 -08:00
dragBox3D . status ! = DRAG_RELEASED & & ! ignoreOrder & & ! mouseOverConsole & & ! bDisplayMultiJoiningStatus )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
{
dealWithRMB ( ) ;
}
else
{
2012-02-25 16:21:29 -08:00
if ( ! bMultiPlayer & & ( establishSelection ( selectedPlayer ) = = SC_DROID_TRANSPORTER | | establishSelection ( selectedPlayer ) = = SC_DROID_SUPERTRANSPORTER ) )
2010-11-01 16:54:50 -07:00
{
// Never, *ever* let user control the transport in SP games--it breaks the scripts!
ASSERT ( game . type = = CAMPAIGN , " Game type was set incorrectly! " ) ;
return ;
}
else
{
dealWithLMB ( ) ;
}
2009-03-12 02:25:29 -07:00
}
2007-06-28 10:47:08 -07:00
}
if ( mouseDClicked ( MOUSE_LMB ) )
{
dealWithLMBDClick ( ) ;
}
2006-05-27 09:37:17 -07:00
2009-03-12 02:25:29 -07:00
if ( driveModeActive ( ) & & ! driveTacticalActive ( ) )
{
2007-06-28 10:47:08 -07:00
driveProcessAquireButton ( ) ;
2009-03-12 02:25:29 -07:00
}
else
{
if ( ! driveModeActive ( ) )
{
if ( mouseReleased ( MOUSE_RMB ) & & ! rotActive & & ! ignoreRMBC )
2007-06-28 10:47:08 -07:00
{
dragBox3D . status = DRAG_INACTIVE ;
// Pretty sure we wan't set walldrag status here aswell.
2006-05-27 09:37:17 -07:00
wallDrag . status = DRAG_INACTIVE ;
2008-03-24 09:51:17 -07:00
bRadarDragging = false ;
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
{
dealWithLMB ( ) ;
}
else
{
dealWithRMB ( ) ;
}
2007-06-28 10:47:08 -07:00
// Why?
if ( getWarCamStatus ( ) )
{
camToggleStatus ( ) ;
}
}
2009-03-12 02:25:29 -07:00
if ( ! mouseDrag ( MOUSE_SELECT , ( UDWORD * ) & rotX , ( UDWORD * ) & rotY ) & & bRadarDragging )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
bRadarDragging = false ;
2007-06-28 10:47:08 -07:00
}
/* Right mouse click kills a building placement */
2009-03-12 02:25:29 -07:00
if ( mouseReleased ( MOUSE_RMB ) & &
2007-02-10 08:39:39 -08:00
( buildState = = BUILD3D_POS | | buildState = = BUILD3D_VALID ) )
2007-06-28 10:47:08 -07:00
{
/* Stop the placement */
kill3DBuilding ( ) ;
2008-03-24 09:51:17 -07:00
bRadarDragging = false ;
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
if ( mouseReleased ( MOUSE_RMB ) )
{
cancelDeliveryRepos ( ) ;
}
2010-07-15 18:26:34 -07:00
if ( mouseDrag ( MOUSE_ROTATE , ( UDWORD * ) & rotX , ( UDWORD * ) & rotY ) & & ! rotActive & & ! bRadarDragging )
2007-06-28 10:47:08 -07:00
{
rotInitial = player . r . y ;
rotInitialUp = player . r . x ;
xMoved = 0 ;
yMoved = 0 ;
2008-03-24 09:51:17 -07:00
rotActive = true ;
2007-06-28 10:47:08 -07:00
}
}
}
selection = establishSelection ( selectedPlayer ) ;
2006-08-23 05:58:48 -07:00
ASSERT ( selection < = POSSIBLE_SELECTIONS , " Weirdy selection! " ) ;
2007-06-28 10:47:08 -07:00
2010-05-02 09:27:26 -07:00
if ( gamePaused ( ) )
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_DEFAULT ) ;
2010-05-02 09:27:26 -07:00
}
if ( buildState = = BUILD3D_VALID )
{
// special casing for building
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_BUILD ) ;
2010-05-02 09:27:26 -07:00
}
else if ( buildState = = BUILD3D_POS )
{
// special casing for building - can't build here
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_NOTPOSSIBLE ) ;
2010-05-02 09:27:26 -07:00
}
else if ( selection ! = SC_INVALID )
2007-06-28 10:47:08 -07:00
{
BASE_OBJECT * ObjUnderMouse ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
bool ObjAllied ;
2007-06-28 10:47:08 -07:00
item = itemUnderMouse ( & ObjUnderMouse ) ;
2006-08-23 05:58:48 -07:00
ASSERT ( item < POSSIBLE_TARGETS , " Weirdy target! " ) ;
2007-06-28 10:47:08 -07:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
ObjAllied = ( ObjUnderMouse & & selectedPlayer ! = ObjUnderMouse - > player & & aiCheckAlliances ( selectedPlayer , ObjUnderMouse - > player ) ) ;
2007-06-28 10:47:08 -07:00
2006-05-27 09:37:17 -07:00
if ( item ! = MT_NOTARGET )
2007-06-28 10:47:08 -07:00
{
2006-05-27 09:37:17 -07:00
// exceptions to the lookup table.
2007-06-28 10:47:08 -07:00
if ( ctrlShiftDown ( ) & &
( ObjUnderMouse ! = NULL ) & &
( ObjUnderMouse - > player = = selectedPlayer ) & &
( ObjUnderMouse - > type = = OBJ_DROID ) )
{
item = MT_OWNDROID ;
}
2011-03-21 15:56:08 -07:00
else if ( specialOrderKeyDown ( ) & &
2007-06-28 10:47:08 -07:00
( ObjUnderMouse ! = NULL ) & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
ObjUnderMouse - > player = = selectedPlayer )
2007-06-28 10:47:08 -07:00
{
if ( selection = = SC_DROID_REPAIR )
{
item = MT_OWNDROIDDAM ;
}
else
{
// attacking own unit
item = MT_ENEMYDROID ;
}
}
2012-03-19 21:04:33 -07:00
else if ( selection = = SC_DROID_REPAIR )
{
// We can't repair ourselves, so change it to a blocking cursor
for ( DROID * psCurr = apsDroidLists [ selectedPlayer ] ; psCurr ! = NULL ; psCurr = psCurr - > psNext )
{
if ( psCurr - > selected )
{
if ( ( ObjUnderMouse ! = NULL ) & & ObjUnderMouse - > player = = selectedPlayer & & psCurr - > id = = ObjUnderMouse - > id )
{
item = MT_BLOCKING ;
}
break ;
}
}
}
2012-03-01 18:01:37 -08:00
else if ( selection = = SC_DROID_DEMOLISH )
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
{
2012-03-01 18:01:37 -08:00
// Can't demolish allied objects, or something that isn't built yet
2012-03-16 20:53:52 -07:00
if ( ObjAllied | | ( ObjUnderMouse & & ( ObjUnderMouse - > type ! = OBJ_STRUCTURE | | ( ( ( STRUCTURE * ) ObjUnderMouse ) - > status = = SS_BLUEPRINT_PLANNED ) ) ) )
2012-03-01 18:01:37 -08:00
{
item = MT_BLOCKING ;
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2010-10-17 14:14:36 -07:00
// in multiPlayer check for what kind of unit can use it (TODO)
2007-05-29 19:06:46 -07:00
else if ( bMultiPlayer & & item = = MT_TRANDROID )
{
2010-10-17 14:14:36 -07:00
if ( ObjUnderMouse - > player ! = selectedPlayer )
2007-05-29 19:06:46 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
item = MT_OWNDROID ;
2007-05-29 19:06:46 -07:00
}
}
2007-06-28 10:47:08 -07:00
else if ( selection = = SC_DROID_CONSTRUCT )
{
// We don't allow the build cursor under certain circumstances ....
// can't build if res extractors arent available.
if ( item = = MT_RESOURCE )
{
2010-12-20 09:16:45 -08:00
for ( i = 0 ; i < numStructureStats & & asStructureStats [ i ] . type ! = REF_RESOURCE_EXTRACTOR ; i + + ) { } // find resource stat
if ( i < numStructureStats & & apStructTypeLists [ selectedPlayer ] [ i ] ! = AVAILABLE ) // check if you can build it!
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
{
2010-12-20 09:16:45 -08:00
item = MT_BLOCKING ; // don't allow build pointer.
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2007-06-28 10:47:08 -07:00
}
// repair instead of sensor/guard with cons. droids.
else if ( item = = MT_SENSOR )
{
if ( ObjUnderMouse // something valid
& & ( ObjUnderMouse - > type = = OBJ_STRUCTURE ) ) // check if struct
{
if ( buildingDamaged ( ( STRUCTURE * ) ObjUnderMouse ) )
{
item = MT_OWNSTRDAM ; // replace guard/sense with usual icons.
} else {
item = MT_OWNSTROK ;
}
}
}
}
2006-05-27 09:37:17 -07:00
else if ( item = = MT_SENSOR
2007-02-10 08:39:39 -08:00
& & selection = = SC_DROID_INDIRECT
& & ( keyDown ( KEY_LSHIFT ) | | keyDown ( KEY_RSHIFT ) ) )
2007-06-28 10:47:08 -07:00
{
selection = SC_DROID_SENSOR ;
}
// check the type of sensor for indirect weapons
2007-02-10 08:39:39 -08:00
else if ( ( item = = MT_SENSOR | | item = = MT_SENSORSTRUCT | | item = = MT_SENSORSTRUCTDAM )
& & selection = = SC_DROID_INDIRECT )
2007-06-28 10:47:08 -07:00
{
if ( ! droidSensorDroidWeapon ( ObjUnderMouse , psDominantSelected ) )
{
item = MT_BLOCKING ;
}
}
//check for VTOL droids being assigned to a sensor droid/structure
2007-02-10 08:39:39 -08:00
else if ( ( item = = MT_SENSOR | | item = = MT_SENSORSTRUCT | | item = = MT_SENSORSTRUCTDAM )
& & selection = = SC_DROID_DIRECT
& & vtolDroidSelected ( ( UBYTE ) selectedPlayer ) )
2007-06-28 10:47:08 -07:00
{
// NB. psSelectedVtol was set by vtolDroidSelected - yes I know its horrible, but it
// only smells as much as the rest of display.c so I don't feel so bad
if ( droidSensorDroidWeapon ( ObjUnderMouse , psSelectedVtol ) )
{
selection = SC_DROID_INDIRECT ;
}
else
{
item = MT_BLOCKING ;
}
}
2010-05-02 09:27:26 -07:00
2007-05-29 19:06:46 -07:00
//vtols cannot pick up artifacts
else if ( item = = MT_ARTIFACT
2007-02-10 08:39:39 -08:00
& & selection = = SC_DROID_DIRECT
& & vtolDroidSelected ( ( UBYTE ) selectedPlayer ) )
2007-05-29 19:06:46 -07:00
{
item = MT_BLOCKING ;
}
2007-06-28 10:47:08 -07:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( item = = MT_TERRAIN
& & terrainType ( mapTile ( mouseTileX , mouseTileY ) ) = = TER_CLIFFFACE )
2007-06-28 10:47:08 -07:00
{
item = MT_BLOCKING ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
// special droid at full health
if ( arnMPointers [ item ] [ selection ] = = CURSOR_FIX & & ObjUnderMouse - > type = = OBJ_DROID & &
! droidIsDamaged ( ( DROID * ) ObjUnderMouse ) )
2007-05-29 19:06:46 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
item = MT_OWNDROID ;
2007-05-29 19:06:46 -07:00
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( ( arnMPointers [ item ] [ selection ] = = CURSOR_SELECT | |
2010-05-02 09:27:26 -07:00
arnMPointers [ item ] [ selection ] = = CURSOR_EMBARK | |
arnMPointers [ item ] [ selection ] = = CURSOR_ATTACH | |
arnMPointers [ item ] [ selection ] = = CURSOR_LOCKON | |
arnMPointers [ item ] [ selection ] = = CURSOR_DEST ) & & ObjAllied )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
// If you want to do these things, just gift your unit to your ally.
2007-06-28 10:47:08 -07:00
item = MT_BLOCKING ;
}
2010-05-02 09:27:26 -07:00
2012-02-25 16:21:29 -08:00
if ( specialOrderKeyDown ( ) & & ( selection = = SC_DROID_TRANSPORTER | | selection = = SC_DROID_SUPERTRANSPORTER ) & &
2009-12-18 16:24:41 -08:00
arnMPointers [ item ] [ selection ] = = CURSOR_MOVE & & bMultiPlayer )
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
{
// Alt+move = disembark transporter
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_DISEMBARK ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2011-03-21 15:56:08 -07:00
else if ( specialOrderKeyDown ( ) & & selection = = SC_DROID_DIRECT & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
arnMPointers [ item ] [ selection ] = = CURSOR_MOVE )
{
// Alt+move = scout
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_SCOUT ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
else if ( arnMPointers [ item ] [ selection ] = = CURSOR_NOTPOSSIBLE & &
ObjUnderMouse & & ( ObjUnderMouse - > player = = selectedPlayer ) & &
ObjUnderMouse - > type = = OBJ_STRUCTURE & & ( ( STRUCTURE * ) ObjUnderMouse ) - > asWeaps [ 0 ] . nStat & &
( asWeaponStats [ ( ( STRUCTURE * ) ObjUnderMouse ) - > asWeaps [ 0 ] . nStat ] . weaponSubClass = = WSC_LAS_SAT ) )
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_SELECT ) ; // Special casing for LasSat
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
else
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( arnMPointers [ item ] [ selection ] ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2007-06-28 10:47:08 -07:00
}
2010-05-02 09:27:26 -07:00
else
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_DEFAULT ) ;
2010-05-02 09:27:26 -07:00
}
2006-05-27 09:37:17 -07:00
}
2007-06-28 10:47:08 -07:00
else
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
BASE_OBJECT * ObjUnderMouse ;
item = itemUnderMouse ( & ObjUnderMouse ) ;
2007-05-29 19:06:46 -07:00
//exceptions, exceptions...AB 10/06/99
if ( bMultiPlayer & & bLasSatStruct )
{
ASSERT ( item < POSSIBLE_TARGETS , " Weirdy target! " ) ;
if ( item = = MT_ENEMYDROID | | item = = MT_ENEMYSTR | | item = = MT_DAMFEATURE )
{
//display attack cursor
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_ATTACK ) ;
2007-05-29 19:06:46 -07:00
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else if ( ObjUnderMouse & & ObjUnderMouse - > player = = selectedPlayer & & ( ObjUnderMouse - > type = = OBJ_DROID | |
( ObjUnderMouse - > type = = OBJ_STRUCTURE & & lasSatStructSelected ( ( STRUCTURE * ) ObjUnderMouse ) ) ) )
{
// Special casing for selectables
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_SELECT ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
else if ( ObjUnderMouse & & ObjUnderMouse - > player = = selectedPlayer & & ObjUnderMouse - > type = = OBJ_STRUCTURE )
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_DEFAULT ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2007-05-29 19:06:46 -07:00
else
{
//display block cursor
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_NOTPOSSIBLE ) ;
2007-05-29 19:06:46 -07:00
}
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else if ( ObjUnderMouse & & ( ObjUnderMouse - > player = = selectedPlayer ) & &
( ( ObjUnderMouse - > type = = OBJ_STRUCTURE & & ( ( STRUCTURE * ) ObjUnderMouse ) - > asWeaps [ 0 ] . nStat
& & ( asWeaponStats [ ( ( STRUCTURE * ) ObjUnderMouse ) - > asWeaps [ 0 ] . nStat ] . weaponSubClass = = WSC_LAS_SAT ) )
| | ObjUnderMouse - > type = = OBJ_DROID ) )
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_SELECT ) ; // Special casing for LasSat or own unit
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2007-05-29 19:06:46 -07:00
else
{
2011-07-14 14:10:35 -07:00
wzSetCursor ( CURSOR_DEFAULT ) ;
2007-05-29 19:06:46 -07:00
}
2007-06-28 10:47:08 -07:00
}
2010-05-02 09:27:26 -07:00
CurrentItemUnderMouse = item ;
2007-06-28 10:47:08 -07:00
}
2010-12-02 11:38:56 -08:00
static void calcScroll ( float * y , float * dydt , float accel , float decel , float targetVelocity , float dt )
2010-12-01 04:33:44 -08:00
{
2010-12-02 11:38:56 -08:00
double tMid ;
2010-12-01 04:33:44 -08:00
2011-11-16 00:48:58 -08:00
// Stop instantly, if trying to change direction.
if ( targetVelocity * * dydt < - 1e-8 f )
{
* dydt = 0 ;
}
2010-12-02 11:38:56 -08:00
if ( targetVelocity < * dydt )
2010-12-01 04:33:44 -08:00
{
accel = - accel ;
2010-12-02 11:38:56 -08:00
decel = - decel ;
2010-12-01 04:33:44 -08:00
}
2010-12-02 11:38:56 -08:00
// Decelerate if needed.
tMid = ( 0 - * dydt ) / decel ;
CLIP ( tMid , 0 , dt ) ;
* y + = * dydt * tMid + decel / 2 * tMid * tMid ;
* dydt + = decel * tMid ;
dt - = tMid ;
// Accelerate if needed.
tMid = ( targetVelocity - * dydt ) / accel ;
CLIP ( tMid , 0 , dt ) ;
* y + = * dydt * tMid + accel / 2 * tMid * tMid ;
2010-12-01 04:33:44 -08:00
* dydt + = accel * tMid ;
2010-12-02 11:38:56 -08:00
dt - = tMid ;
// Continue at target velocity.
* y + = * dydt * dt ;
2010-12-01 04:33:44 -08:00
}
2007-06-28 10:47:08 -07:00
void scroll ( void )
{
SDWORD xDif , yDif ;
2010-12-08 18:34:54 -08:00
uint32_t timeDiff ;
2010-12-01 04:33:44 -08:00
int scrollDirLeftRight = 0 , scrollDirUpDown = 0 ;
2007-12-17 12:32:17 -08:00
float scroll_zoom_factor = 1 + 2 * ( ( getViewDistance ( ) - MINDISTANCE ) / ( ( float ) ( MAXDISTANCE - MINDISTANCE ) ) ) ;
float scaled_max_scroll_speed = scroll_zoom_factor * MAX_SCROLL_SPEED ;
float scaled_accel ;
2007-06-28 10:47:08 -07:00
2012-01-11 07:28:30 -08:00
static float xDiffFrac = 0 , yDiffFrac = 0 ;
2009-12-18 16:37:09 -08:00
if ( InGameOpUp | | bDisplayMultiJoiningStatus | | isInGamePopupUp ) // cant scroll when menu up. or when over radar
2007-06-28 10:47:08 -07:00
{
return ;
}
2011-12-26 05:51:02 -08:00
if ( mouseScroll & & wzMouseInWindow ( ) )
2007-06-28 10:47:08 -07:00
{
2010-12-01 04:33:44 -08:00
// Scroll left or right
scrollDirLeftRight + = ( mouseX ( ) > ( pie_GetVideoBufferWidth ( ) - BOUNDARY_X ) ) -
( mouseX ( ) < BOUNDARY_X ) ;
2007-06-28 10:47:08 -07:00
2010-12-01 04:33:44 -08:00
// Scroll down or up
scrollDirUpDown + = ( mouseY ( ) < BOUNDARY_Y ) -
( mouseY ( ) > ( pie_GetVideoBufferHeight ( ) - BOUNDARY_Y ) ) ;
2007-06-28 10:47:08 -07:00
}
2010-01-23 19:39:44 -08:00
if ( ! keyDown ( KEY_LCTRL ) & & ! keyDown ( KEY_RCTRL ) )
2007-06-28 10:47:08 -07:00
{
2010-12-01 04:33:44 -08:00
// Scroll left or right
scrollDirLeftRight + = keyDown ( KEY_RIGHTARROW ) - keyDown ( KEY_LEFTARROW ) ;
2006-05-27 09:37:17 -07:00
2010-12-01 04:33:44 -08:00
// Scroll down or up
scrollDirUpDown + = keyDown ( KEY_UPARROW ) - keyDown ( KEY_DOWNARROW ) ;
2007-06-28 10:47:08 -07:00
}
2010-12-01 04:33:44 -08:00
CLIP ( scrollDirLeftRight , - 1 , 1 ) ;
CLIP ( scrollDirUpDown , - 1 , 1 ) ;
2007-05-29 19:06:46 -07:00
2012-01-11 07:28:30 -08:00
if ( scrollDirLeftRight ! = 0 | | scrollDirUpDown ! = 0 )
{
setWarCamActive ( false ) ; // Don't let this thing override the user trying to scroll.
}
2010-12-01 04:33:44 -08:00
scaled_accel = scroll_zoom_factor * scroll_speed_accel ;
2007-06-28 10:47:08 -07:00
2010-12-08 18:34:54 -08:00
// Apparently there's stutter if using deltaRealTime, so we have our very own delta time here, just for us.
timeDiff = wzGetTicks ( ) - scrollRefTime ;
scrollRefTime + = timeDiff ;
2011-12-26 05:51:02 -08:00
timeDiff = std : : min < unsigned > ( timeDiff , 500 ) ; // Since we're using our own time variable, which isn't updated when dragging a box, clamp the time here so releasing the box doesn't scroll to the edge of the map suddenly.
2010-12-08 18:34:54 -08:00
2010-12-01 04:33:44 -08:00
scrollStepLeftRight = 0 ;
scrollStepUpDown = 0 ;
2010-12-08 18:34:54 -08:00
calcScroll ( & scrollStepLeftRight , & scrollSpeedLeftRight , scaled_accel , 2 * scaled_accel , scrollDirLeftRight * scaled_max_scroll_speed , ( float ) timeDiff / GAME_TICKS_PER_SEC ) ;
calcScroll ( & scrollStepUpDown , & scrollSpeedUpDown , scaled_accel , 2 * scaled_accel , scrollDirUpDown * scaled_max_scroll_speed , ( float ) timeDiff / GAME_TICKS_PER_SEC ) ;
2007-06-28 10:47:08 -07:00
2007-05-29 19:06:46 -07:00
/* Get x component of movement */
2012-01-11 07:28:30 -08:00
xDiffFrac + = cos ( - player . r . y * ( M_PI / 32768 ) ) * scrollStepLeftRight + sin ( - player . r . y * ( M_PI / 32768 ) ) * scrollStepUpDown ;
2007-06-28 10:47:08 -07:00
/* Get y component of movement */
2012-01-11 07:28:30 -08:00
yDiffFrac + = sin ( - player . r . y * ( M_PI / 32768 ) ) * scrollStepLeftRight - cos ( - player . r . y * ( M_PI / 32768 ) ) * scrollStepUpDown ;
xDif = ( int ) xDiffFrac ;
yDif = ( int ) yDiffFrac ;
xDiffFrac - = xDif ;
yDiffFrac - = yDif ;
2007-06-28 10:47:08 -07:00
/* Adjust player's position by these components */
player . p . x + = xDif ;
player . p . z + = yDif ;
edgeOfMap = CheckScrollLimits ( ) ;
}
2010-01-23 15:28:41 -08:00
/*
* Reset scrolling , so we don ' t jump around after unpausing .
*/
void resetScroll ( void )
{
2010-12-08 18:34:54 -08:00
scrollRefTime = wzGetTicks ( ) ;
2010-01-23 15:28:41 -08:00
scrollSpeedUpDown = 0.0f ;
scrollSpeedLeftRight = 0.0f ;
}
2007-06-28 10:47:08 -07:00
// Check a coordinate is within the scroll limits, SDWORD version.
2008-03-24 09:51:17 -07:00
// Returns true if edge hit.
2007-06-28 10:47:08 -07:00
//
2011-03-12 17:32:15 -08:00
bool CheckInScrollLimits ( SDWORD * xPos , SDWORD * zPos )
2007-06-28 10:47:08 -07:00
{
2011-03-12 17:32:15 -08:00
bool EdgeHit = false ;
2007-06-28 10:47:08 -07:00
SDWORD minX , minY , maxX , maxY ;
2011-04-30 09:41:50 -07:00
minX = world_coord ( scrollMinX ) ;
maxX = world_coord ( scrollMaxX - 1 ) ;
minY = world_coord ( scrollMinY ) ;
maxY = world_coord ( scrollMaxY - 1 ) ;
2006-05-27 09:37:17 -07:00
2007-06-28 10:47:08 -07:00
//scroll is limited to what can be seen for current campaign
if ( * xPos < minX )
{
* xPos = minX ;
2008-03-24 09:51:17 -07:00
EdgeHit = true ;
2007-06-28 10:47:08 -07:00
}
else
if ( * xPos > = maxX )
{
* xPos = maxX ;
2008-03-24 09:51:17 -07:00
EdgeHit = true ;
2007-06-28 10:47:08 -07:00
}
if ( * zPos < minY )
{
* zPos = minY ;
2008-03-24 09:51:17 -07:00
EdgeHit = true ;
2007-06-28 10:47:08 -07:00
}
else
if ( * zPos > = maxY )
{
* zPos = maxY ;
2008-03-24 09:51:17 -07:00
EdgeHit = true ;
2007-06-28 10:47:08 -07:00
}
return EdgeHit ;
}
// Check the view is within the scroll limits,
2008-03-24 09:51:17 -07:00
// Returns true if edge hit.
2007-06-28 10:47:08 -07:00
//
2011-03-12 17:32:15 -08:00
bool CheckScrollLimits ( void )
2007-06-28 10:47:08 -07:00
{
SDWORD xp = player . p . x ;
SDWORD zp = player . p . z ;
2011-03-12 17:32:15 -08:00
bool ret = CheckInScrollLimits ( & xp , & zp ) ;
2007-06-28 10:47:08 -07:00
player . p . x = xp ;
player . p . z = zp ;
return ret ;
}
/* Do the 3D display */
void displayWorld ( void )
{
2007-03-16 09:20:16 -07:00
Vector3i pos ;
2011-07-14 14:10:35 -07:00
2007-06-28 10:47:08 -07:00
shakeUpdate ( ) ;
2010-07-15 18:26:34 -07:00
if ( mouseDown ( MOUSE_ROTATE ) & & rotActive )
2007-06-28 10:47:08 -07:00
{
2010-03-14 10:26:09 -07:00
if ( abs ( mouseX ( ) - rotX ) > 2 | | xMoved > 2 | | abs ( mouseY ( ) - rotY ) > 2 | | yMoved > 2 )
2007-06-28 10:47:08 -07:00
{
2010-03-10 04:31:27 -08:00
xMoved + = abs ( mouseX ( ) - rotX ) ;
if ( mouseX ( ) < rotX )
2007-06-28 10:47:08 -07:00
{
2010-03-14 10:26:09 -07:00
player . r . y = rotInitial + ( rotX - mouseX ( ) ) * DEG ( 1 ) / 2 ;
2007-06-28 10:47:08 -07:00
}
else
{
2010-03-14 10:26:09 -07:00
player . r . y = rotInitial - ( mouseX ( ) - rotX ) * DEG ( 1 ) / 2 ;
2007-05-29 19:06:46 -07:00
}
2010-03-10 04:31:27 -08:00
yMoved + = abs ( mouseY ( ) - rotY ) ;
2007-05-29 19:06:46 -07:00
if ( bInvertMouse )
2007-06-28 10:47:08 -07:00
{
2010-03-10 04:31:27 -08:00
if ( mouseY ( ) < rotY )
2007-06-28 10:47:08 -07:00
{
2010-03-14 10:26:09 -07:00
player . r . x = rotInitialUp + ( rotY - mouseY ( ) ) * DEG ( 1 ) / 3 ;
2007-06-28 10:47:08 -07:00
}
else
{
2010-03-14 10:26:09 -07:00
player . r . x = rotInitialUp - ( mouseY ( ) - rotY ) * DEG ( 1 ) / 3 ;
2006-05-27 09:37:17 -07:00
}
2007-06-28 10:47:08 -07:00
}
else
{
2010-03-10 04:31:27 -08:00
if ( mouseY ( ) < rotY )
2007-06-28 10:47:08 -07:00
{
2010-03-14 10:26:09 -07:00
player . r . x = rotInitialUp - ( rotY - mouseY ( ) ) * DEG ( 1 ) / 3 ;
2007-06-28 10:47:08 -07:00
}
else
{
2010-03-14 10:26:09 -07:00
player . r . x = rotInitialUp + ( mouseY ( ) - rotY ) * DEG ( 1 ) / 3 ;
2007-06-28 10:47:08 -07:00
}
}
2007-05-29 19:06:46 -07:00
if ( player . r . x > DEG ( 360 + MAX_PLAYER_X_ANGLE ) )
2007-06-28 10:47:08 -07:00
{
player . r . x = DEG ( 360 + MAX_PLAYER_X_ANGLE ) ;
}
if ( player . r . x < DEG ( 360 + MIN_PLAYER_X_ANGLE ) )
{
player . r . x = DEG ( 360 + MIN_PLAYER_X_ANGLE ) ;
}
setDesiredPitch ( player . r . x / DEG_1 ) ;
}
}
2010-07-15 18:26:34 -07:00
if ( ! mouseDown ( MOUSE_ROTATE ) & & rotActive )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
rotActive = false ;
2007-06-28 10:47:08 -07:00
xMoved = yMoved = 0 ;
2008-03-24 09:51:17 -07:00
ignoreRMBC = true ;
2007-06-28 10:47:08 -07:00
pos . x = player . r . x ;
pos . y = player . r . y ;
pos . z = player . r . z ;
camInformOfRotation ( & pos ) ;
2008-03-24 09:51:17 -07:00
bRadarDragging = false ;
2007-06-28 10:47:08 -07:00
}
draw3DScene ( ) ;
}
2011-03-12 17:32:15 -08:00
static bool mouseInBox ( SDWORD x0 , SDWORD y0 , SDWORD x1 , SDWORD y1 )
2007-06-28 10:47:08 -07:00
{
2010-03-10 04:31:27 -08:00
return mouseX ( ) > x0 & & mouseX ( ) < x1 & & mouseY ( ) > y0 & & mouseY ( ) < y1 ;
2007-06-28 10:47:08 -07:00
}
2011-03-12 17:32:15 -08:00
bool DrawnInLastFrame ( int32_t frame )
2007-06-28 10:47:08 -07:00
{
2010-02-06 09:12:53 -08:00
return frame > = ( int32_t ) StartOfLastFrame ;
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
/*
2007-06-28 10:47:08 -07:00
Returns what the mouse was clicked on . Only called if there was a mouse pressed message
2006-05-27 09:37:17 -07:00
on MOUSE_LMB . We aren ' t concerned here with setting selection flags - just what it
actually was
2007-06-28 10:47:08 -07:00
*/
2013-03-05 14:59:02 -08:00
BASE_OBJECT * mouseTarget ( )
2007-06-28 10:47:08 -07:00
{
2013-03-05 14:59:02 -08:00
BASE_OBJECT * psReturn = NULL ;
int dispX , dispY , dispR ;
if ( mouseTileX < 0 | | mouseTileY < 0 | | mouseTileX > mapWidth - 1 | | mouseTileY > mapHeight - 1 )
2007-06-28 10:47:08 -07:00
{
return ( NULL ) ;
}
/* First have a look through the droid lists */
2013-03-05 14:59:02 -08:00
for ( int i = 0 ; i < MAX_PLAYERS ; i + + )
2007-06-28 10:47:08 -07:00
{
/* Note the !psObject check isn't really necessary as the goto will jump out */
2013-03-05 14:59:02 -08:00
for ( DROID * psDroid = apsDroidLists [ i ] ; psDroid & & ! psReturn ; psDroid = psDroid - > psNext )
2007-06-28 10:47:08 -07:00
{
dispX = psDroid - > sDisplay . screenX ;
dispY = psDroid - > sDisplay . screenY ;
dispR = psDroid - > sDisplay . screenR ;
2012-08-01 01:06:52 -07:00
// Has the droid been drawn since the start of the last frame
2013-03-05 14:59:02 -08:00
if ( psDroid - > visible [ selectedPlayer ] & & DrawnInLastFrame ( psDroid - > sDisplay . frameNumber ) )
2007-06-28 10:47:08 -07:00
{
2013-03-05 14:59:02 -08:00
if ( mouseInBox ( dispX - dispR , dispY - dispR , dispX + dispR , dispY + dispR ) )
2007-06-28 10:47:08 -07:00
{
/* We HAVE clicked on droid! */
psReturn = ( BASE_OBJECT * ) psDroid ;
/* There's no point in checking other object types */
2013-03-05 14:59:02 -08:00
return psReturn ;
2007-06-28 10:47:08 -07:00
}
}
}
} // end of checking for droids
2006-05-27 09:37:17 -07:00
/* Not a droid, so maybe a structure or feature?
2007-06-28 10:47:08 -07:00
If still NULL after this then nothing */
psReturn = getTileOccupier ( mouseTileX , mouseTileY ) ;
2010-12-20 18:24:32 -08:00
if ( psReturn = = NULL )
{
2011-11-17 04:14:56 -08:00
psReturn = getTileBlueprintStructure ( mouseTileX , mouseTileY ) ;
2010-12-20 18:24:32 -08:00
}
2007-05-29 19:06:46 -07:00
/* Send the result back - if it's null then we clicked on an area of terrain */
2013-03-05 14:59:02 -08:00
return psReturn ;
2007-06-28 10:47:08 -07:00
}
// Start repositioning a delivery point.
//
2012-06-21 15:34:04 -07:00
static FLAG_POSITION flagPos ;
static int flagStructId ;
static bool flagReposVarsValid ;
static bool flagReposFinished ;
void startDeliveryPosition ( FLAG_POSITION * psFlag )
2007-06-28 10:47:08 -07:00
{
FLAG_POSITION * psFlagPos ;
2007-10-29 12:58:27 -07:00
2012-06-21 15:34:04 -07:00
if ( tryingToGetLocation ( ) ) // if we're placing a building don't place
{
return ;
}
//clear the selected delivery point
2012-12-30 02:58:45 -08:00
for ( psFlagPos = apsFlagPosLists [ selectedPlayer ] ; psFlagPos ; psFlagPos = psFlagPos - > psNext )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
psFlagPos - > selected = false ;
2007-06-28 10:47:08 -07:00
}
//set this object position to be highlighted
2012-06-21 15:34:04 -07:00
psFlag - > selected = true ;
flagPos = * psFlag ;
2007-06-28 10:47:08 -07:00
2012-06-21 15:34:04 -07:00
STRUCTURE * psStruct = findDeliveryFactory ( psFlag ) ;
if ( ! psStruct )
2007-06-28 10:47:08 -07:00
{
2012-06-21 15:34:04 -07:00
flagStructId = 0 ; // not a struct, just a flag.
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
else
{
flagStructId = psStruct - > id ;
}
flagReposVarsValid = true ;
flagReposFinished = false ;
2007-06-28 10:47:08 -07:00
2012-06-21 15:34:04 -07:00
if ( bInTutorial )
{
eventFireCallbackTrigger ( ( TRIGGER_TYPE ) CALL_DELIVPOINTMOVED ) ;
}
2007-06-28 10:47:08 -07:00
}
// Finished repositioning a delivery point.
//
2012-06-21 15:34:04 -07:00
void finishDeliveryPosition ( )
2007-06-28 10:47:08 -07:00
{
2012-06-21 15:34:04 -07:00
FLAG_POSITION * psFlagPos ;
if ( flagStructId )
{
flagReposVarsValid = false ;
STRUCTURE * psStruct = IdToStruct ( flagStructId , selectedPlayer ) ;
if ( StructIsFactory ( psStruct ) & & psStruct - > pFunctionality
& & psStruct - > pFunctionality - > factory . psAssemblyPoint )
{
setAssemblyPoint ( psStruct - > pFunctionality - > factory . psAssemblyPoint ,
flagPos . coords . x , flagPos . coords . y , selectedPlayer , true ) ;
}
2013-10-04 10:16:49 -07:00
else if ( psStruct - > pStructureType - > type = = REF_REPAIR_FACILITY & & psStruct - > pFunctionality ! = NULL )
2012-06-29 18:07:52 -07:00
{
setAssemblyPoint ( psStruct - > pFunctionality - > repairFacility . psDeliveryPoint ,
flagPos . coords . x , flagPos . coords . y , selectedPlayer , true ) ;
}
2012-06-21 15:34:04 -07:00
//deselect once moved
2012-12-30 02:58:45 -08:00
for ( psFlagPos = apsFlagPosLists [ selectedPlayer ] ; psFlagPos ; psFlagPos = psFlagPos - > psNext )
2012-06-21 15:34:04 -07:00
{
psFlagPos - > selected = false ;
}
}
flagReposFinished = true ;
2007-06-28 10:47:08 -07:00
}
// Is there a valid delivery point repositioning going on.
2012-06-21 15:34:04 -07:00
bool deliveryReposValid ( void )
2007-06-28 10:47:08 -07:00
{
2012-06-21 15:34:04 -07:00
if ( ! flagReposVarsValid )
return false ;
Vector2i map = map_coord ( removeZ ( flagPos . coords ) ) ;
//make sure we are not too near map edge
if ( map . x < scrollMinX + TOO_NEAR_EDGE | | map . x + 1 > scrollMaxX - TOO_NEAR_EDGE | |
map . y < scrollMinY + TOO_NEAR_EDGE | | map . y + 1 > scrollMaxY - TOO_NEAR_EDGE )
{
return false ;
}
// cant place on top of a delivery point...
for ( FLAG_POSITION const * psCurrFlag = apsFlagPosLists [ selectedPlayer ] ; psCurrFlag ; psCurrFlag = psCurrFlag - > psNext )
{
Vector2i flagTile = map_coord ( removeZ ( psCurrFlag - > coords ) ) ;
if ( flagTile = = map )
return false ;
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
if ( fpathBlockingTile ( map . x , map . y , PROPULSION_TYPE_WHEELED ) )
{
return false ;
}
return true ;
}
bool deliveryReposFinished ( FLAG_POSITION * psFlag )
{
if ( ! flagReposVarsValid )
return false ;
if ( psFlag )
* psFlag = flagPos ;
return flagReposFinished ;
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
void processDeliveryRepos ( void )
{
if ( ! flagReposVarsValid )
return ;
int bX = clip ( mouseTileX , 2 , mapWidth - 3 ) ;
int bY = clip ( mouseTileY , 2 , mapHeight - 3 ) ;
flagPos . coords = Vector3i ( world_coord ( Vector2i ( bX , bY ) ) + Vector2i ( TILE_UNITS / 2 , TILE_UNITS / 2 ) , map_TileHeight ( bX , bY ) + 2 * ASSEMBLY_POINT_Z_PADDING ) ;
}
2007-06-28 10:47:08 -07:00
// Cancel repositioning of the delivery point without moving it.
//
2012-06-21 15:34:04 -07:00
void cancelDeliveryRepos ( void )
2007-06-28 10:47:08 -07:00
{
2012-06-21 15:34:04 -07:00
flagReposVarsValid = false ;
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
void renderDeliveryRepos ( void )
{
if ( flagReposVarsValid )
renderDeliveryPoint ( & flagPos , true ) ;
}
2007-06-28 10:47:08 -07:00
// check whether a clicked on droid is in a command group or assigned to a sensor
2011-03-12 17:32:15 -08:00
static bool droidHasLeader ( DROID * psDroid )
2007-06-28 10:47:08 -07:00
{
BASE_OBJECT * psLeader ;
if ( psDroid - > droidType = = DROID_COMMAND | |
psDroid - > droidType = = DROID_SENSOR )
{
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
2008-04-15 08:15:19 -07:00
if ( hasCommander ( psDroid ) )
2007-06-28 10:47:08 -07:00
{
psLeader = ( BASE_OBJECT * ) psDroid - > psGroup - > psCommander ;
}
else
{
2007-05-29 19:06:46 -07:00
//psLeader can be either a droid or a structure
2008-03-11 07:44:03 -07:00
psLeader = orderStateObj ( psDroid , DORDER_FIRESUPPORT ) ;
2007-06-28 10:47:08 -07:00
}
if ( psLeader ! = NULL )
{
2007-05-29 19:06:46 -07:00
if ( psLeader - > type = = OBJ_DROID )
{
SelectDroid ( ( DROID * ) psLeader ) ;
}
2007-06-28 10:47:08 -07:00
assignSensorTarget ( psLeader ) ;
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
// deal with selecting a droid
2011-03-12 17:32:15 -08:00
void dealWithDroidSelect ( DROID * psDroid , bool bDragBox )
2007-06-28 10:47:08 -07:00
{
DROID * psD ;
2011-03-12 17:32:15 -08:00
bool bGotGroup ;
2007-06-28 10:47:08 -07:00
/* Toggle selection on and off - allows you drag around a big
area of droids and then exclude certain individuals */
2010-03-11 04:17:15 -08:00
if ( ! bDragBox & & psDroid - > selected = = true )
2007-06-28 10:47:08 -07:00
{
DeSelectDroid ( psDroid ) ;
}
2010-03-11 04:17:15 -08:00
else if ( ctrlShiftDown ( ) | | ! droidHasLeader ( psDroid ) )
2007-06-28 10:47:08 -07:00
{
2010-03-11 04:17:15 -08:00
for ( psD = apsDroidLists [ selectedPlayer ] , bGotGroup = false ; psD & & ! bGotGroup ; psD = psD - > psNext )
2007-06-28 10:47:08 -07:00
{
2007-02-10 08:39:39 -08:00
if ( psD - > selected & & ( psD - > group ! = UBYTE_MAX ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
bGotGroup = true ;
2007-06-28 10:47:08 -07:00
}
}
2011-03-21 15:56:08 -07:00
if ( specialOrderKeyDown ( ) )
2007-06-28 10:47:08 -07:00
{
/* We only want to select weapon units if ALT is down on a drag */
2010-03-11 04:17:15 -08:00
if ( psDroid - > asWeaps [ 0 ] . nStat > 0 )
2007-06-28 10:47:08 -07:00
{
SelectDroid ( psDroid ) ;
}
}
else
{
2009-06-17 20:45:16 -07:00
SelectDroid ( psDroid ) ;
2007-06-28 10:47:08 -07:00
}
2010-03-11 04:17:15 -08:00
psCBSelectedDroid = psDroid ;
eventFireCallbackTrigger ( ( TRIGGER_TYPE ) CALL_DROID_SELECTED ) ;
psCBSelectedDroid = NULL ;
2007-06-28 10:47:08 -07:00
}
}
2006-09-14 06:15:40 -07:00
static void FeedbackOrderGiven ( void )
2007-06-28 10:47:08 -07:00
{
static UDWORD LastFrame = 0 ;
UDWORD ThisFrame = frameGetFrameNumber ( ) ;
// Ensure only played once per game cycle.
if ( ThisFrame ! = LastFrame ) {
audio_PlayTrack ( ID_SOUND_SELECT ) ;
LastFrame = ThisFrame ;
}
}
// check whether the queue order keys are pressed
2011-03-12 17:32:15 -08:00
bool ctrlShiftDown ( void )
2007-06-28 10:47:08 -07:00
{
return keyDown ( KEY_LCTRL ) | | keyDown ( KEY_RCTRL ) | | keyDown ( KEY_LSHIFT ) | | keyDown ( KEY_RSHIFT ) ;
}
void AddDerrickBurningMessage ( void )
{
2008-03-30 10:59:13 -07:00
addConsoleMessage ( _ ( " Cannot Build. Oil Resource Burning. " ) , DEFAULT_JUSTIFY , SYSTEM_MESSAGE ) ;
2007-06-28 10:47:08 -07:00
audio_PlayTrack ( ID_SOUND_BUILD_FAIL ) ;
}
2013-05-20 13:13:37 -07:00
static void printDroidClickInfo ( DROID * psDroid )
{
if ( getDebugMappingStatus ( ) ) // cheating on, so output debug info
{
console ( " %s - Hitpoints %d/%d - ID %d - experience %f, %s - order %s - action %s - sensor range %hu - ECM %u - pitch %.0f - frust %u " ,
droidGetName ( psDroid ) , psDroid - > body , psDroid - > originalBody , psDroid - > id ,
psDroid - > experience / 65536.f , getDroidLevelName ( psDroid ) , getDroidOrderName ( psDroid - > order . type ) , getDroidActionName ( psDroid - > action ) ,
droidSensorRange ( psDroid ) , droidJammerPower ( psDroid ) , UNDEG ( psDroid - > rot . pitch ) , psDroid - > lastFrustratedTime ) ;
FeedbackOrderGiven ( ) ;
}
else if ( ! psDroid - > selected )
{
console ( _ ( " %s - Hitpoints %d/%d - Experience %.1f, %s " ) , droidGetName ( psDroid ) , psDroid - > body , psDroid - > originalBody ,
psDroid - > experience / 65536.f , _ ( getDroidLevelName ( psDroid ) ) ) ;
FeedbackOrderGiven ( ) ;
}
clearSelection ( ) ;
dealWithDroidSelect ( psDroid , false ) ;
}
2010-04-05 13:23:57 -07:00
static void dealWithLMBDroid ( DROID * psDroid , SELECTION_TYPE selection )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
bool ownDroid ; // Not an allied droid
if ( ! aiCheckAlliances ( selectedPlayer , psDroid - > player ) )
2007-06-17 14:02:57 -07:00
{
2009-04-26 14:35:32 -07:00
memset ( DROIDDOING , 0x0 , sizeof ( DROIDDOING ) ) ; // take over the other players droid by debug menu.
2013-05-20 13:13:37 -07:00
/* We've clicked on enemy droid */
2011-07-10 15:49:24 -07:00
if ( getDebugMappingStatus ( ) )
{
2013-05-20 13:13:37 -07:00
console ( " (Enemy!) %s - Hitpoints %d/%d - ID %d - experience %f, %s - order %s - action %s - sensor range %d - ECM %d - pitch %.0f " ,
droidGetName ( psDroid ) , psDroid - > body , psDroid - > originalBody , psDroid - > id ,
psDroid - > experience / 65536.f , getDroidLevelName ( psDroid ) , getDroidOrderName ( psDroid - > order . type ) ,
getDroidActionName ( psDroid - > action ) , droidSensorRange ( psDroid ) , droidJammerPower ( psDroid ) , UNDEG ( psDroid - > rot . pitch ) ) ;
2011-07-10 15:49:24 -07:00
FeedbackOrderGiven ( ) ;
}
2007-06-17 14:02:57 -07:00
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psDroid , ctrlShiftDown ( ) ) ;
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
//lasSat structure can select a target - in multiPlayer only
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( bMultiPlayer & & bLasSatStruct )
2007-06-17 14:02:57 -07:00
{
orderStructureObj ( selectedPlayer , ( BASE_OBJECT * ) psDroid ) ;
}
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
FeedbackOrderGiven ( ) ;
driveDisableTactical ( ) ;
2007-06-28 10:47:08 -07:00
return ;
}
2007-06-18 08:46:12 -07:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
ownDroid = ( selectedPlayer = = psDroid - > player ) ;
2009-03-12 02:25:29 -07:00
// Hack to detect if sensor was assigned
bSensorAssigned = true ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( ! bRightClickOrders & & ctrlShiftDown ( ) & & ownDroid )
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
// select/deselect etc. the droid
2008-03-24 09:51:17 -07:00
dealWithDroidSelect ( psDroid , false ) ;
2007-06-28 10:47:08 -07:00
}
2011-03-21 15:56:08 -07:00
else if ( specialOrderKeyDown ( ) & & ownDroid )
2007-06-17 14:02:57 -07:00
{
// try to attack your own unit
2010-02-10 15:15:32 -08:00
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psDroid , ctrlShiftDown ( ) ) ;
FeedbackOrderGiven ( ) ;
driveDisableTactical ( ) ;
2007-06-17 14:02:57 -07:00
}
2012-02-25 16:21:29 -08:00
else if ( psDroid - > droidType = = DROID_TRANSPORTER | | psDroid - > droidType = = DROID_SUPERTRANSPORTER )
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
{
if ( selection = = SC_INVALID )
{
//in multiPlayer mode we RMB to get the interface up
if ( bMultiPlayer & & ! bRightClickOrders )
{
psDroid - > selected = true ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
else
{
intResetScreen ( false ) ;
if ( ! getWidgetsStatus ( ) )
{
setWidgetsStatus ( true ) ;
}
addTransporterInterface ( psDroid , false ) ;
}
}
2010-10-17 14:14:36 -07:00
else
{ // We can order all units to use the transport now
if ( cyborgDroidSelected ( selectedPlayer ) )
{
// TODO add special processing for cyborgDroids
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
orderSelectedObj ( selectedPlayer , ( BASE_OBJECT * ) psDroid ) ;
FeedbackOrderGiven ( ) ;
}
}
2007-06-17 14:02:57 -07:00
// Clicked on a commander? Will link to it.
2009-03-12 02:25:29 -07:00
else if ( psDroid - > droidType = = DROID_COMMAND & & selection ! = SC_INVALID & &
selection ! = SC_DROID_COMMAND & &
selection ! = SC_DROID_CONSTRUCT & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
! ctrlShiftDown ( ) & & ownDroid )
2007-06-17 14:02:57 -07:00
{
2008-03-24 09:51:17 -07:00
turnOffMultiMsg ( true ) ;
2007-06-17 14:02:57 -07:00
orderSelectedObj ( selectedPlayer , ( BASE_OBJECT * ) psDroid ) ;
FeedbackOrderGiven ( ) ;
clearSelection ( ) ;
assignSensorTarget ( ( BASE_OBJECT * ) psDroid ) ;
2008-03-24 09:51:17 -07:00
dealWithDroidSelect ( psDroid , false ) ;
turnOffMultiMsg ( false ) ;
2007-06-17 14:02:57 -07:00
}
2009-03-12 02:25:29 -07:00
// Clicked on a sensor? Will assign to it.
else if ( psDroid - > droidType = = DROID_SENSOR )
{
DROID * psCurr ;
bSensorAssigned = false ;
for ( psCurr = apsDroidLists [ selectedPlayer ] ; psCurr ; psCurr = psCurr - > psNext )
{
//must be indirect weapon droid or VTOL weapon droid
if ( ( psCurr - > droidType = = DROID_WEAPON ) & &
( psCurr - > selected ) & &
( psCurr - > asWeaps [ 0 ] . nStat > 0 ) & &
( ( ! proj_Direct ( asWeaponStats + psCurr - > asWeaps [ 0 ] . nStat ) ) | |
isVtolDroid ( psCurr ) ) & &
droidSensorDroidWeapon ( ( BASE_OBJECT * ) psDroid , psCurr ) )
{
bSensorAssigned = true ;
2010-10-24 08:12:43 -07:00
orderDroidObj ( psCurr , DORDER_FIRESUPPORT , ( BASE_OBJECT * ) psDroid , ModeQueue ) ;
2009-03-12 02:25:29 -07:00
FeedbackOrderGiven ( ) ;
}
}
if ( bSensorAssigned )
{
2010-01-15 18:49:16 -08:00
clearSelection ( ) ;
2009-03-12 02:25:29 -07:00
assignSensorTarget ( ( BASE_OBJECT * ) psDroid ) ;
}
}
// Hack to detect if anything was done with sensor
else
{
bSensorAssigned = false ;
}
if ( bSensorAssigned )
{
return ;
}
2007-06-17 14:02:57 -07:00
// Clicked on a construction unit? Will guard it.
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else if ( ( psDroid - > droidType = = DROID_CONSTRUCT | | psDroid - > droidType = = DROID_SENSOR | |
psDroid - > droidType = = DROID_COMMAND )
& & selection = = SC_DROID_DIRECT )
2007-06-17 14:02:57 -07:00
{
orderSelectedObj ( selectedPlayer , ( BASE_OBJECT * ) psDroid ) ;
FeedbackOrderGiven ( ) ;
}
// Clicked on a damaged unit? Will repair it.
else if ( droidIsDamaged ( psDroid ) & & repairDroidSelected ( selectedPlayer ) )
{
assignDestTarget ( ) ;
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psDroid , ctrlShiftDown ( ) ) ;
FeedbackOrderGiven ( ) ;
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else if ( bRightClickOrders & & ownDroid )
2009-03-12 02:25:29 -07:00
{
if ( ! ( psDroid - > selected ) )
{
clearSelection ( ) ;
SelectDroid ( psDroid ) ;
}
intObjectSelected ( ( BASE_OBJECT * ) psDroid ) ;
}
2007-06-17 14:02:57 -07:00
// Just plain clicked on?
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else if ( ownDroid )
2007-06-17 14:02:57 -07:00
{
2013-05-20 13:13:37 -07:00
printDroidClickInfo ( psDroid ) ;
2007-06-17 14:02:57 -07:00
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else // Clicked on allied unit with no other possible actions
{
2013-05-20 13:13:37 -07:00
console ( _ ( " %s - Allied - Hitpoints %d/%d - Experience %d, %s " ) , droidGetName ( psDroid ) , psDroid - > body , psDroid - > originalBody ,
psDroid - > experience / 65536 , getDroidLevelName ( psDroid ) ) ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
FeedbackOrderGiven ( ) ;
}
2007-06-17 14:02:57 -07:00
}
2007-06-28 10:47:08 -07:00
2010-04-05 13:23:57 -07:00
static void dealWithLMBStructure ( STRUCTURE * psStructure , SELECTION_TYPE selection )
2007-06-17 14:02:57 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
bool ownStruct = ( psStructure - > player = = selectedPlayer ) ;
2007-06-17 14:02:57 -07:00
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( ! aiCheckAlliances ( psStructure - > player , selectedPlayer ) )
2007-06-17 14:02:57 -07:00
{
2013-05-20 13:13:37 -07:00
/* We've clicked on an enemy building */
2011-07-10 15:49:24 -07:00
if ( getDebugMappingStatus ( ) )
{
2013-05-20 13:13:37 -07:00
console ( " (Enemy!) %s, ref: %d, ID: %d Hitpoints: %d/%d " , getID ( psStructure - > pStructureType ) , psStructure - > pStructureType - > ref ,
psStructure - > id , psStructure - > body , psStructure - > pStructureType - > upgrade [ psStructure - > player ] . hitpoints ) ;
2011-07-10 15:49:24 -07:00
}
2007-06-17 14:02:57 -07:00
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psStructure , ctrlShiftDown ( ) ) ;
//lasSat structure can select a target - in multiPlayer only
if ( bMultiPlayer & & bLasSatStruct )
{
orderStructureObj ( selectedPlayer , ( BASE_OBJECT * ) psStructure ) ;
}
FeedbackOrderGiven ( ) ;
driveDisableTactical ( ) ;
return ;
}
2007-06-28 10:47:08 -07:00
2013-05-20 13:13:37 -07:00
/* We've clicked on allied or own building */
2007-06-17 14:02:57 -07:00
//print some info at the top of the screen for the specific structure
2009-03-12 02:25:29 -07:00
if ( ! bRightClickOrders ) printStructureInfo ( psStructure ) ;
2007-06-17 14:02:57 -07:00
/* Got to be built. Also, you can't 'select' derricks */
2011-03-21 15:56:08 -07:00
if ( ! specialOrderKeyDown ( ) & & ( psStructure - > status = = SS_BUILT ) & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
( psStructure - > pStructureType - > type ! = REF_RESOURCE_EXTRACTOR ) & & ownStruct )
2007-06-17 14:02:57 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
{
if ( StructIsFactory ( psStructure ) & & selection ! = SC_DROID_CONSTRUCT )
{
intAddFactoryOrder ( psStructure ) ;
}
2007-06-17 14:02:57 -07:00
}
2009-03-12 02:25:29 -07:00
else
{
// now only display interface if nothing selected
if ( ! anyDroidSelected ( selectedPlayer ) )
{
intObjectSelected ( ( BASE_OBJECT * ) psStructure ) ;
FeedbackOrderGiven ( ) ;
}
if ( selection = = SC_INVALID )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
STRUCTURE * psCurr ;
/* Clear old building selection(s) - should only be one */
for ( psCurr = apsStructLists [ selectedPlayer ] ; psCurr ; psCurr = psCurr - > psNext )
{
psCurr - > selected = false ;
}
/* Establish new one */
psStructure - > selected = true ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
2007-06-28 10:47:08 -07:00
}
2009-03-12 02:25:29 -07:00
//determine if LasSat structure has been selected
bLasSatStruct = lasSatStructSelected ( psStructure ) ;
2007-06-17 14:02:57 -07:00
}
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
}
2009-03-12 02:25:29 -07:00
else if ( ( psStructure - > status = = SS_BUILT ) & &
2007-06-17 14:02:57 -07:00
( psStructure - > pStructureType - > type = = REF_RESOURCE_EXTRACTOR ) & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
selection = = SC_INVALID & & ownStruct )
2007-06-17 14:02:57 -07:00
{
STRUCTURE * psCurr ;
2007-06-18 08:46:12 -07:00
2007-06-17 14:02:57 -07:00
/* Clear old building selection(s) - should only be one */
2009-03-12 02:25:29 -07:00
for ( psCurr = apsStructLists [ selectedPlayer ] ; psCurr ; psCurr = psCurr - > psNext )
2007-06-17 14:02:57 -07:00
{
2008-03-24 09:51:17 -07:00
psCurr - > selected = false ;
2007-06-17 14:02:57 -07:00
}
/* Establish new one */
2008-03-24 09:51:17 -07:00
psStructure - > selected = true ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
2007-06-17 14:02:57 -07:00
}
2010-02-10 15:15:32 -08:00
bSensorAssigned = false ;
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psStructure , ctrlShiftDown ( ) ) ;
FeedbackOrderGiven ( ) ;
if ( bSensorAssigned )
2007-06-17 14:02:57 -07:00
{
2010-02-10 15:15:32 -08:00
clearSelection ( ) ;
assignSensorTarget ( ( BASE_OBJECT * ) psStructure ) ;
2007-06-17 14:02:57 -07:00
}
2010-05-02 12:22:09 -07:00
if ( intDemolishSelectMode ( ) )
{
// we were demolishing something - now we're done
if ( ctrlShiftDown ( ) )
{
quickQueueMode = true ;
}
else
{
intDemolishCancel ( ) ;
}
}
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
driveDisableTactical ( ) ;
}
2007-06-28 10:47:08 -07:00
2010-04-05 13:23:57 -07:00
static void dealWithLMBFeature ( FEATURE * psFeature )
2007-06-17 14:02:57 -07:00
{
//go on to check for
if ( psFeature - > psStats - > damageable )
{
orderSelectedObjAdd ( selectedPlayer , ( BASE_OBJECT * ) psFeature , ctrlShiftDown ( ) ) ;
//lasSat structure can select a target - in multiPlayer only
if ( bMultiPlayer & & bLasSatStruct )
{
orderStructureObj ( selectedPlayer , ( BASE_OBJECT * ) psFeature ) ;
}
FeedbackOrderGiven ( ) ;
}
2006-05-27 09:37:17 -07:00
2007-06-17 14:02:57 -07:00
//clicking an oil field should start a build..
if ( psFeature - > psStats - > subType = = FEAT_OIL_RESOURCE )
{
unsigned int i ;
// find any construction droids. and order them to build an oil resource.
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
// first find the derrick.
2010-12-16 19:05:06 -08:00
for ( i = 0 ; ( i < numStructureStats ) & & ( asStructureStats [ i ] . type ! = REF_RESOURCE_EXTRACTOR ) ; + + i ) { }
2007-06-17 14:02:57 -07:00
if ( ( i < numStructureStats ) & &
( apStructTypeLists [ selectedPlayer ] [ i ] = = AVAILABLE ) ) // dont go any further if no derrick stat found.
{
DROID * psCurr ;
2007-06-18 08:46:12 -07:00
2007-06-17 14:02:57 -07:00
// for each droid
for ( psCurr = apsDroidLists [ selectedPlayer ] ; psCurr ; psCurr = psCurr - > psNext )
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
if ( ( droidType ( psCurr ) = = DROID_CONSTRUCT | |
droidType ( psCurr ) = = DROID_CYBORG_CONSTRUCT ) & & ( psCurr - > selected ) )
2007-06-28 10:47:08 -07:00
{
2007-12-15 07:39:29 -08:00
if ( fireOnLocation ( psFeature - > pos . x , psFeature - > pos . y ) )
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
// Can't build because it's burning
AddDerrickBurningMessage ( ) ;
2007-06-28 10:47:08 -07:00
}
2007-06-18 08:46:12 -07:00
2012-01-01 06:01:28 -08:00
sendDroidInfo ( psCurr , DroidOrder ( DORDER_BUILD , & asStructureStats [ i ] , removeZ ( psFeature - > pos ) , player . r . y ) , ctrlShiftDown ( ) ) ;
2011-12-06 08:44:18 -08:00
FeedbackOrderGiven ( ) ;
2007-06-28 10:47:08 -07:00
}
}
2006-05-27 09:37:17 -07:00
}
2007-06-28 10:47:08 -07:00
}
2007-06-17 14:02:57 -07:00
else
{
switch ( psFeature - > psStats - > subType )
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
case FEAT_GEN_ARTE :
case FEAT_OIL_DRUM :
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
DROID * psNearestUnit = getNearestDroid ( mouseTileX * TILE_UNITS + TILE_UNITS / 2 ,
2008-03-24 09:51:17 -07:00
mouseTileY * TILE_UNITS + TILE_UNITS / 2 , true ) ;
2007-06-17 14:02:57 -07:00
/* If so then find the nearest unit! */
2009-03-12 02:25:29 -07:00
if ( psNearestUnit ) // bloody well should be!!!
2007-06-17 14:02:57 -07:00
{
2012-01-01 06:01:28 -08:00
sendDroidInfo ( psNearestUnit , DroidOrder ( DORDER_RECOVER , psFeature ) , ctrlShiftDown ( ) ) ;
2007-06-17 14:02:57 -07:00
FeedbackOrderGiven ( ) ;
}
break ;
}
case FEAT_BOULDER :
case FEAT_OIL_RESOURCE :
case FEAT_VEHICLE :
default :
break ;
}
}
2013-05-20 13:13:37 -07:00
if ( getDebugMappingStatus ( ) )
{
console ( " (Feature) %s ID: %d ref: %d Hipoints: %d/%d " , getID ( psFeature - > psStats ) , psFeature - > id , psFeature - > psStats - > ref , psFeature - > psStats - > body , psFeature - > body ) ;
}
2007-06-17 14:02:57 -07:00
driveDisableTactical ( ) ;
}
2007-06-14 13:59:04 -07:00
2010-04-05 13:23:57 -07:00
static void dealWithLMBObject ( BASE_OBJECT * psClickedOn )
2007-06-17 14:02:57 -07:00
{
SELECTION_TYPE selection = establishSelection ( selectedPlayer ) ;
2010-01-08 12:15:56 -08:00
OBJECT_TYPE type = psClickedOn - > type ;
2007-06-14 13:59:04 -07:00
2010-01-08 12:15:56 -08:00
switch ( type )
2007-06-17 14:02:57 -07:00
{
case OBJ_DROID :
dealWithLMBDroid ( ( DROID * ) psClickedOn , selection ) ;
break ;
2007-06-18 08:46:12 -07:00
2007-06-17 14:02:57 -07:00
case OBJ_STRUCTURE :
dealWithLMBStructure ( ( STRUCTURE * ) psClickedOn , selection ) ;
break ;
case OBJ_FEATURE :
dealWithLMBFeature ( ( FEATURE * ) psClickedOn ) ;
break ;
default :
2010-01-08 12:15:56 -08:00
// assert only when the value is outside of the valid range
2010-08-15 03:03:38 -07:00
ASSERT ( type < OBJ_NUM_TYPES , " Weird selection from LMB - type of clicked object is %d " , ( int ) type ) ;
2008-05-11 04:04:38 -07:00
break ;
2007-06-17 14:02:57 -07:00
}
}
void dealWithLMB ( void )
{
BASE_OBJECT * psClickedOn ;
OBJECT_POSITION * psLocation ;
2009-03-12 02:25:29 -07:00
STRUCTURE * psStructure ;
2007-06-17 14:02:57 -07:00
/* Don't process if in game options are on screen */
2009-03-12 02:25:29 -07:00
if ( mouseOverRadar | |
InGameOpUp = = true | | widgGetFromID ( psWScreen , INTINGAMEOP ) )
2007-06-17 14:02:57 -07:00
{
return ;
}
/* What have we clicked on? */
if ( driveModeActive ( ) & & ! driveTacticalActive ( ) )
{
2010-04-05 13:27:22 -07:00
psClickedOn = NULL ;
2007-06-17 14:02:57 -07:00
if ( psClickedOn )
{
dealWithLMBObject ( psClickedOn ) ;
2007-06-28 10:47:08 -07:00
}
2007-06-17 14:02:57 -07:00
return ;
}
else
{
psClickedOn = mouseTarget ( ) ;
if ( psClickedOn )
2007-06-28 10:47:08 -07:00
{
2007-06-17 14:02:57 -07:00
dealWithLMBObject ( psClickedOn ) ;
return ;
}
}
/*Check for a Delivery Point or a Proximity Message*/
psLocation = checkMouseLoc ( ) ;
if ( psLocation = = NULL | | driveModeActive ( ) | | selNumSelected ( selectedPlayer ) )
{
// now changed to use the multiple order stuff
2010-01-20 10:08:46 -08:00
// clicked on a destination.
2011-03-03 14:15:40 -08:00
orderSelectedLoc ( selectedPlayer , mousePos . x , mousePos . y , ctrlShiftDown ( ) ) ; // ctrlShiftDown() = ctrl clicked a destination, add an order
2010-01-20 10:08:46 -08:00
/* Otherwise send them all */
if ( getNumDroidsSelected ( ) )
2007-06-17 14:02:57 -07:00
{
2010-01-20 10:08:46 -08:00
assignDestTarget ( ) ;
audio_PlayTrack ( ID_SOUND_SELECT ) ;
2007-06-17 14:02:57 -07:00
}
2010-01-20 10:08:46 -08:00
if ( getDebugMappingStatus ( ) & & tileOnMap ( mouseTileX , mouseTileY ) )
{
MAPTILE * psTile = mapTile ( mouseTileX , mouseTileY ) ;
2010-11-21 14:21:23 -08:00
uint8_t aux = auxTile ( mouseTileX , mouseTileY , selectedPlayer ) ;
2007-06-28 10:47:08 -07:00
2013-05-20 13:13:37 -07:00
console ( " %s tile %d, %d [%d, %d] continent(l%d, h%d) level %g illum %d %s %s w=%d s=%d j=%d " ,
2010-01-20 10:08:46 -08:00
tileIsExplored ( psTile ) ? " Explored " : " Unexplored " ,
mouseTileX , mouseTileY , world_coord ( mouseTileX ) , world_coord ( mouseTileY ) ,
2011-07-14 14:10:35 -07:00
( int ) psTile - > limitedContinent , ( int ) psTile - > hoverContinent , psTile - > level , ( int ) psTile - > illumination ,
2011-10-16 12:01:58 -07:00
aux & AUXBITS_DANGER ? " danger " : " " , aux & AUXBITS_THREAT ? " threat " : " " ,
2013-05-20 13:13:37 -07:00
( int ) psTile - > watchers [ selectedPlayer ] , ( int ) psTile - > sensors [ selectedPlayer ] , ( int ) psTile - > jammers [ selectedPlayer ] ) ;
2007-06-17 14:02:57 -07:00
}
2007-06-18 08:46:12 -07:00
2007-06-17 14:02:57 -07:00
driveDisableTactical ( ) ;
2007-06-28 10:47:08 -07:00
2007-06-17 14:02:57 -07:00
return ;
}
switch ( psLocation - > type )
{
case POS_DELIVERY :
if ( psLocation - > player = = selectedPlayer )
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
{
//centre the view on the owning Factory
psStructure = findDeliveryFactory ( ( FLAG_POSITION * ) psLocation ) ;
if ( psStructure )
{
setViewPos ( map_coord ( psStructure - > pos . x ) ,
map_coord ( psStructure - > pos . y ) ,
true ) ;
}
}
else
{
2012-06-21 15:34:04 -07:00
startDeliveryPosition ( ( FLAG_POSITION * ) psLocation ) ;
2009-03-12 02:25:29 -07:00
}
2007-06-17 14:02:57 -07:00
}
break ;
default :
ASSERT ( ! " unknown object position type " , " Unknown type from checkMouseLoc " ) ;
2007-06-28 10:47:08 -07:00
}
}
2011-03-12 17:32:15 -08:00
bool getRotActive ( void )
2007-06-28 10:47:08 -07:00
{
return ( rotActive ) ;
}
SDWORD getDesiredPitch ( void )
{
return ( desiredPitch ) ;
}
void setDesiredPitch ( SDWORD pitch )
{
desiredPitch = pitch ;
}
// process LMB double clicks
2007-11-20 14:18:17 -08:00
static void dealWithLMBDClick ( void )
2007-06-28 10:47:08 -07:00
{
BASE_OBJECT * psClickedOn ;
DROID * psDroid ;
2009-03-12 02:25:29 -07:00
STRUCTURE * psStructure ;
2007-06-28 10:47:08 -07:00
/* What have we clicked on? */
psClickedOn = mouseTarget ( ) ;
/* If not NULL, then it's a droid or a structure */
if ( psClickedOn ! = NULL )
{
/* We've got a droid or a structure */
if ( psClickedOn - > type = = OBJ_DROID )
{
/* We clicked on droid */
psDroid = ( DROID * ) psClickedOn ;
if ( psDroid - > player = = selectedPlayer )
{
/* If we've double clicked on a constructor droid, activate build menu */
2010-03-21 07:58:36 -07:00
if ( psDroid - > droidType = = DROID_COMMAND )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
intResetScreen ( true ) ;
2007-06-28 10:47:08 -07:00
intCommanderSelected ( psDroid ) ;
}
else
{
2010-03-21 07:58:36 -07:00
// Now selects all of same type on screen
2008-03-24 09:51:17 -07:00
selDroidSelection ( selectedPlayer , DS_BY_TYPE , DST_ALL_SAME , true ) ;
2007-06-28 10:47:08 -07:00
}
}
}
2009-03-12 02:25:29 -07:00
else if ( psClickedOn - > type = = OBJ_STRUCTURE )
{
/* We clicked on structure */
psStructure = ( STRUCTURE * ) psClickedOn ;
2011-01-13 06:55:06 -08:00
if ( psStructure - > player = = selectedPlayer & & ! structureIsBlueprint ( psStructure ) )
2009-03-12 02:25:29 -07:00
{
if ( StructIsFactory ( psStructure ) )
{
setViewPos ( map_coord ( psStructure - > pFunctionality - > factory . psAssemblyPoint - > coords . x ) ,
map_coord ( psStructure - > pFunctionality - > factory . psAssemblyPoint - > coords . y ) ,
true ) ;
}
else if ( psStructure - > pStructureType - > type = = REF_REPAIR_FACILITY )
{
setViewPos ( map_coord ( psStructure - > pFunctionality - > repairFacility . psDeliveryPoint - > coords . x ) ,
map_coord ( psStructure - > pFunctionality - > repairFacility . psDeliveryPoint - > coords . y ) ,
true ) ;
}
}
}
2007-06-28 10:47:08 -07:00
}
}
/*This checks to see if the mouse was over a delivery point or a proximity message
2007-05-29 19:06:46 -07:00
when the mouse button was pressed */
2007-11-20 14:18:17 -08:00
static OBJECT_POSITION * checkMouseLoc ( void )
2007-06-28 10:47:08 -07:00
{
FLAG_POSITION * psPoint ;
UDWORD i ;
UDWORD dispX , dispY , dispR ;
// First have a look through the DeliveryPoint lists
for ( i = 0 ; i < MAX_PLAYERS ; i + + )
{
//new way, handles multiple points.
for ( psPoint = apsFlagPosLists [ i ] ; psPoint ; psPoint = psPoint - > psNext )
{
dispX = psPoint - > screenX ;
dispY = psPoint - > screenY ;
dispR = psPoint - > screenR ;
2008-03-24 09:51:17 -07:00
if ( DrawnInLastFrame ( psPoint - > frameNumber ) = = true ) // Only check DP's that are on screen
2007-06-28 10:47:08 -07:00
{
if ( mouseInBox ( dispX - dispR , dispY - dispR , dispX + dispR , dispY + dispR ) )
{
// We HAVE clicked on DP!
2010-12-21 08:33:05 -08:00
return psPoint ;
2007-06-28 10:47:08 -07:00
}
}
}
}
return NULL ;
}
2007-11-20 14:18:17 -08:00
static void dealWithRMB ( void )
2007-06-28 10:47:08 -07:00
{
BASE_OBJECT * psClickedOn ;
DROID * psDroid ;
STRUCTURE * psStructure ;
2009-03-12 02:25:29 -07:00
if ( driveModeActive ( ) | | mouseOverRadar | |
InGameOpUp = = true | | widgGetFromID ( psWScreen , INTINGAMEOP ) )
{
2007-06-28 10:47:08 -07:00
return ;
}
/* What have we clicked on? */
psClickedOn = mouseTarget ( ) ;
/* If not NULL, then it's a droid or a structure */
2009-03-12 02:25:29 -07:00
if ( psClickedOn ! = NULL )
2007-06-28 10:47:08 -07:00
{
/* We've got a droid or a structure */
2009-03-12 02:25:29 -07:00
if ( psClickedOn - > type = = OBJ_DROID )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
/* We clicked on droid */
psDroid = ( DROID * ) psClickedOn ;
if ( psDroid - > player = = selectedPlayer )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders & & ctrlShiftDown ( ) )
{
dealWithDroidSelect ( psDroid , false ) ;
}
// Not a transporter
2012-02-25 16:21:29 -08:00
else if ( psDroid - > droidType ! = DROID_TRANSPORTER & & psDroid - > droidType ! = DROID_SUPERTRANSPORTER )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
2007-06-28 10:47:08 -07:00
{
/* We've clicked on one of our own droids */
2013-05-20 13:13:37 -07:00
printDroidClickInfo ( psDroid ) ;
2009-03-12 02:25:29 -07:00
}
else
{
if ( psDroid - > selected ! = true )
2007-06-28 10:47:08 -07:00
{
clearSelection ( ) ;
SelectDroid ( psDroid ) ;
}
2009-03-12 02:25:29 -07:00
intObjectSelected ( ( BASE_OBJECT * ) psDroid ) ;
2007-06-28 10:47:08 -07:00
}
2009-03-12 02:25:29 -07:00
}
// Transporter
else
{
if ( bMultiPlayer )
2007-05-29 19:06:46 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders & & psDroid - > selected ! = true )
{
clearSelection ( ) ;
SelectDroid ( psDroid ) ;
}
else
2007-05-29 19:06:46 -07:00
{
2008-03-24 09:51:17 -07:00
intResetScreen ( false ) ;
2009-03-12 02:25:29 -07:00
if ( ! getWidgetsStatus ( ) )
2007-05-29 19:06:46 -07:00
{
2008-03-24 09:51:17 -07:00
setWidgetsStatus ( true ) ;
2007-05-29 19:06:46 -07:00
}
2008-03-24 09:51:17 -07:00
addTransporterInterface ( psDroid , false ) ;
2007-05-29 19:06:46 -07:00
}
}
2007-06-28 10:47:08 -07:00
}
2009-03-12 02:25:29 -07:00
}
2013-05-20 13:13:37 -07:00
else if ( bMultiPlayer & & isHumanPlayer ( psDroid - > player ) )
2009-03-12 02:25:29 -07:00
{
2013-05-20 13:13:37 -07:00
console ( " %s " , droidGetName ( psDroid ) ) ;
FeedbackOrderGiven ( ) ;
2007-06-28 10:47:08 -07:00
}
} // end if its a droid
else if ( psClickedOn - > type = = OBJ_STRUCTURE )
{
2009-03-12 02:25:29 -07:00
/* We clicked on structure */
2007-06-28 10:47:08 -07:00
psStructure = ( STRUCTURE * ) psClickedOn ;
2009-03-12 02:25:29 -07:00
if ( psStructure - > player = = selectedPlayer )
2007-06-28 10:47:08 -07:00
{
/* We've clicked on our own building */
2010-05-02 12:22:09 -07:00
if ( bRightClickOrders & & intDemolishSelectMode ( ) )
2009-03-12 02:25:29 -07:00
{
orderSelectedObjAdd ( selectedPlayer , psClickedOn , ctrlShiftDown ( ) ) ;
FeedbackOrderGiven ( ) ;
2010-05-02 12:22:09 -07:00
// we were demolishing something - now we're done
if ( ctrlShiftDown ( ) )
{
quickQueueMode = true ;
}
else
{
intDemolishCancel ( ) ;
}
2009-03-12 02:25:29 -07:00
}
else if ( psStructure - > selected = = true )
{
2008-03-24 09:51:17 -07:00
psStructure - > selected = false ;
2007-06-28 10:47:08 -07:00
intObjectSelected ( NULL ) ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
2009-03-12 02:25:29 -07:00
}
2011-01-13 06:55:06 -08:00
else if ( ! structureIsBlueprint ( psStructure ) )
2009-03-12 02:25:29 -07:00
{
clearSelection ( ) ;
2007-06-28 10:47:08 -07:00
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
if ( ( psStructure - > status = = SS_BUILT ) & &
( psStructure - > pStructureType - > type ! = REF_RESOURCE_EXTRACTOR ) )
{
printStructureInfo ( psStructure ) ;
psStructure - > selected = true ;
// Open structure menu
intObjectSelected ( ( BASE_OBJECT * ) psStructure ) ;
FeedbackOrderGiven ( ) ;
bLasSatStruct = lasSatStructSelected ( psStructure ) ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
2009-03-12 02:25:29 -07:00
}
2007-06-28 10:47:08 -07:00
}
2009-03-12 02:25:29 -07:00
else if ( StructIsFactory ( psStructure ) )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
//pop up the order interface for the factory
intAddFactoryOrder ( psStructure ) ;
2007-06-28 10:47:08 -07:00
}
else
{
intObjectSelected ( ( BASE_OBJECT * ) psStructure ) ;
}
}
}
} // end if its a structure
2009-03-12 02:25:29 -07:00
else
2006-05-27 09:37:17 -07:00
{
2009-03-12 02:25:29 -07:00
/* And if it's not a feature, then we're in trouble! */
ASSERT ( psClickedOn - > type = = OBJ_FEATURE , " Weird selection from RMB - type of clicked object is %d " , ( int ) psClickedOn - > type ) ;
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
}
2007-06-28 10:47:08 -07:00
else
{
/*Check for a Delivery Point*/
2007-06-14 13:59:04 -07:00
OBJECT_POSITION * psLocation = checkMouseLoc ( ) ;
2007-06-28 10:47:08 -07:00
if ( psLocation )
{
switch ( psLocation - > type )
{
2007-06-14 13:59:04 -07:00
case POS_DELIVERY :
if ( psLocation - > player = = selectedPlayer )
2007-06-28 10:47:08 -07:00
{
2009-03-12 02:25:29 -07:00
if ( bRightClickOrders )
{
2012-06-21 15:34:04 -07:00
startDeliveryPosition ( ( FLAG_POSITION * ) psLocation ) ;
2009-03-12 02:25:29 -07:00
}
else
2007-06-14 13:59:04 -07:00
{
2009-03-12 02:25:29 -07:00
//centre the view on the owning Factory
psStructure = findDeliveryFactory ( ( FLAG_POSITION * ) psLocation ) ;
if ( psStructure )
{
setViewPos ( map_coord ( psStructure - > pos . x ) ,
map_coord ( psStructure - > pos . y ) ,
true ) ;
}
2007-06-14 13:59:04 -07:00
}
2007-06-28 10:47:08 -07:00
}
2007-06-14 13:59:04 -07:00
break ;
default :
ASSERT ( ! " unknown object position type " , " Unknown type from checkMouseLoc " ) ;
2007-06-28 10:47:08 -07:00
}
}
2006-05-27 09:37:17 -07:00
else
2007-06-28 10:47:08 -07:00
{
2012-08-01 01:06:52 -07:00
clearSelection ( ) ;
intObjectSelected ( NULL ) ;
memset ( DROIDDOING , 0x0 , sizeof ( DROIDDOING ) ) ; // clear string when deselected
2007-06-28 10:47:08 -07:00
}
}
}
/* if there is a valid object under the mouse this routine returns not only the type of the object in the
return code , but also a pointer to the BASE_OBJECT ) . . . well if your going to be " object orientated " you might as well do it right
2007-05-29 19:06:46 -07:00
- it sets it to null if we don ' t find anything
2007-06-28 10:47:08 -07:00
*/
static MOUSE_TARGET itemUnderMouse ( BASE_OBJECT * * ppObjectUnderMouse )
{
UDWORD i ;
MOUSE_TARGET retVal ;
BASE_OBJECT * psNotDroid ;
DROID * psDroid ;
UDWORD dispX , dispY , dispR ;
STRUCTURE * psStructure ;
* ppObjectUnderMouse = NULL ;
if ( ! driveModeActive ( ) | | driveTacticalActive ( ) ) {
2007-02-10 08:39:39 -08:00
if ( ( mouseTileX < 0 ) | |
( mouseTileY < 0 ) | |
( mouseTileX > ( SDWORD ) ( mapWidth - 1 ) ) | |
2007-06-28 10:47:08 -07:00
( mouseTileY > ( SDWORD ) ( mapHeight - 1 ) ) )
{
retVal = MT_BLOCKING ;
return ( retVal ) ;
}
}
/* We haven't found anything yet */
retVal = MT_NOTARGET ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
/* First have a look through the droid lists */
for ( i = 0 ; i < MAX_PLAYERS ; i + + )
{
/* Note the !psObject check isn't really necessary as the goto will jump out */
for ( psDroid = apsDroidLists [ i ] ; psDroid & & retVal = = MT_NOTARGET ;
psDroid = psDroid - > psNext )
{
dispX = psDroid - > sDisplay . screenX ;
dispY = psDroid - > sDisplay . screenY ;
dispR = psDroid - > sDisplay . screenR ;
/* Only check droids that're on screen */
if ( psDroid - > sDisplay . frameNumber + 1 = = currentFrame & & psDroid - > visible [ selectedPlayer ] )
{
if ( mouseInBox ( dispX - dispR , dispY - dispR , dispX + dispR , dispY + dispR ) )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
/* We HAVE clicked on droid! */
if ( aiCheckAlliances ( psDroid - > player , selectedPlayer ) )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
* ppObjectUnderMouse = ( BASE_OBJECT * ) psDroid ;
// need to check for command droids here as well
if ( psDroid - > droidType = = DROID_SENSOR )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( selectedPlayer ! = psDroid - > player )
{
retVal = MT_CONSTRUCT ; // Can't assign to allied units
}
else
2007-06-28 10:47:08 -07:00
{
retVal = MT_SENSOR ;
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
2012-02-25 16:21:29 -08:00
else if ( ( psDroid - > droidType = = DROID_TRANSPORTER | | psDroid - > droidType = = DROID_SUPERTRANSPORTER ) & &
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
selectedPlayer = = psDroid - > player )
{
//check the transporter is not full
if ( calcRemainingCapacity ( psDroid ) )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
retVal = MT_TRANDROID ;
2007-06-28 10:47:08 -07:00
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
retVal = MT_BLOCKING ;
2007-06-28 10:47:08 -07:00
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
else if ( psDroid - > droidType = = DROID_CONSTRUCT | |
psDroid - > droidType = = DROID_CYBORG_CONSTRUCT )
{
return MT_CONSTRUCT ;
}
else if ( psDroid - > droidType = = DROID_COMMAND )
{
if ( selectedPlayer ! = psDroid - > player )
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
retVal = MT_CONSTRUCT ; // Can't assign to allied units
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
else
2007-06-28 10:47:08 -07:00
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
retVal = MT_COMMAND ;
2007-06-28 10:47:08 -07:00
}
}
else
{
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( droidIsDamaged ( psDroid ) )
{
retVal = MT_OWNDROIDDAM ;
}
else
{
retVal = MT_OWNDROID ;
}
2007-06-28 10:47:08 -07:00
}
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
else
{
* ppObjectUnderMouse = ( BASE_OBJECT * ) psDroid ;
retVal = MT_ENEMYDROID ;
}
/* There's no point in checking other object types */
return ( retVal ) ;
2007-06-28 10:47:08 -07:00
}
}
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
}
} // end of checking for droids
2007-06-28 10:47:08 -07:00
2006-05-27 09:37:17 -07:00
/* Not a droid, so maybe a structure or feature?
2007-06-28 10:47:08 -07:00
If still NULL after this then nothing */
if ( driveModeActive ( ) & & ! driveTacticalActive ( ) ) {
2010-04-05 13:27:22 -07:00
psNotDroid = NULL ;
2010-12-20 18:24:32 -08:00
}
else
{
2007-06-28 10:47:08 -07:00
psNotDroid = getTileOccupier ( mouseTileX , mouseTileY ) ;
2010-12-20 18:24:32 -08:00
if ( psNotDroid = = NULL )
{
2011-11-17 04:14:56 -08:00
psNotDroid = getTileBlueprintStructure ( mouseTileX , mouseTileY ) ;
2010-12-20 18:24:32 -08:00
}
2007-06-28 10:47:08 -07:00
}
if ( psNotDroid ! = NULL )
{
* ppObjectUnderMouse = ( BASE_OBJECT * ) psNotDroid ;
if ( psNotDroid - > type = = OBJ_FEATURE )
{
if ( ( ( ( FEATURE * ) psNotDroid ) - > psStats - > subType = = FEAT_GEN_ARTE )
| | ( ( ( FEATURE * ) psNotDroid ) - > psStats - > subType = = FEAT_OIL_DRUM ) )
{
retVal = MT_ARTIFACT ;
}
else if ( ( ( FEATURE * ) psNotDroid ) - > psStats - > damageable ) //make damageable features return 'target' mouse pointer
{
retVal = MT_DAMFEATURE ;
}
else if ( ( ( FEATURE * ) psNotDroid ) - > psStats - > subType = = FEAT_OIL_RESOURCE )
{
retVal = MT_RESOURCE ;
}
else
{
retVal = MT_BLOCKING ;
}
}
else if ( psNotDroid - > type = = OBJ_STRUCTURE )
{
psStructure = ( STRUCTURE * ) psNotDroid ;
Commit patch #8421:
* You can now repair allied units.
* You can now repair allied structures.
* You can now upgrade allied structures.
* You can now rearm VTOLs on allied rearming pads.
* You can now repair your units at allied repair facilities.
* You can now guard allied units (trucks, sensors, and commanders) and structures.
* You get a selection cursor when mousing over LasSat, to make it clearer that it's selectable.
* You get the OBSERVE cursor for attack-move, the EMBARK cursor for unload transport, etc.
* A few other minor cursor fixes. Cursors should now reflect what happens when you click on them significantly more of the time.
* Clicking on a transport with no cyborgs selected will select the transport, instead of doing nothing.
* You can attack (and actually damage) your own units/structures with Alt+click, now. Still doesn't work with LasSat, to prevent backstabbing allies by moving an expendable unit into their base. For the same reason, Alt+click only works on your own units, not on your allies'.
* Alt+click works on Mac OS X now.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8433 4a71c877-e1ca-e34f-864e-861f7616d084
2009-11-20 23:09:07 -08:00
if ( aiCheckAlliances ( psNotDroid - > player , selectedPlayer ) )
2007-06-28 10:47:08 -07:00
{
2010-12-20 18:24:32 -08:00
if ( psStructure - > status = = SS_BEING_BUILT | | isBlueprint ( psStructure ) )
2007-06-28 10:47:08 -07:00
{
retVal = MT_OWNSTRINCOMP ;
}
// repair center.
else if ( psStructure - > pStructureType - > type = = REF_REPAIR_FACILITY )
{
if ( buildingDamaged ( psStructure ) )
{
retVal = MT_REPAIRDAM ;
}
else
{
retVal = MT_REPAIR ;
}
}
//sensor tower
2007-02-10 08:39:39 -08:00
else if ( ( psStructure - > pStructureType - > pSensor ) & &
2007-06-28 10:47:08 -07:00
( psStructure - > pStructureType - > pSensor - > location = = LOC_TURRET ) )
{
if ( buildingDamaged ( psStructure ) )
{
2006-11-11 13:29:27 -08:00
retVal = MT_SENSORSTRUCTDAM ;
2007-06-28 10:47:08 -07:00
}
else
2006-05-27 09:37:17 -07:00
{
2006-11-11 13:29:27 -08:00
retVal = MT_SENSORSTRUCT ;
2007-06-28 10:47:08 -07:00
}
}
2006-05-27 09:37:17 -07:00
2007-06-28 10:47:08 -07:00
// standard buildings. - check for buildingDamaged BEFORE upgrades
else if ( buildingDamaged ( psStructure ) )
{
retVal = MT_OWNSTRDAM ;
}
2007-07-08 15:47:13 -07:00
// If this building is a factory/power generator/research facility
// which isn't upgraded. Make the build icon available.
2012-09-20 09:24:17 -07:00
else if ( nextModuleToBuild ( psStructure , - 1 ) > 0 )
2007-06-28 10:47:08 -07:00
{
2012-09-20 09:24:17 -07:00
retVal = MT_OWNSTRINCOMP ;
2007-06-28 10:47:08 -07:00
}
2006-05-27 09:37:17 -07:00
else
2007-06-28 10:47:08 -07:00
{
/* All the different stages of construction */
retVal = MT_OWNSTROK ;
}
}
else
{
retVal = MT_ENEMYSTR ; // enemy structure
}
}
}
2007-05-29 19:06:46 -07:00
/* Send the result back - if it's null then we clicked on an area of terrain */
2007-06-28 10:47:08 -07:00
/* make unseen objects just look like terrain. */
if ( retVal = = MT_NOTARGET | | ! ( psNotDroid - > visible [ selectedPlayer ] ) )
{
retVal = MT_TERRAIN ;
}
return ( retVal ) ;
}
// Indicates the priority given to any given droid
// type in a multiple droid selection, the larger the
// number, the lower the priority. The order of entries
// corresponds to the order of droid types in the DROID_TYPE
// enum in DroidDef.h
//
2012-02-25 16:21:29 -08:00
# define NUM_DROID_WEIGHTS (14)
2012-12-30 04:24:12 -08:00
static UBYTE DroidSelectionWeights [ NUM_DROID_WEIGHTS ] = {
2006-05-27 09:37:17 -07:00
3 , //DROID_WEAPON,
1 , //DROID_SENSOR,
2 , //DROID_ECM,
4 , //DROID_CONSTRUCT,
3 , //DROID_PERSON,
3 , //DROID_CYBORG,
9 , //DROID_TRANSPORTER,
0 , //DROID_COMMAND,
4 , //DROID_REPAIR,
5 , //DROID_DEFAULT,
4 , //DROID_CYBORG_CONSTRUCT,
4 , //DROID_CYBORG_REPAIR,
3 , //DROID_CYBORG_SUPER,
2012-02-28 19:39:41 -08:00
10 , //DROID_SUPERTRANSPORTER
2007-06-28 10:47:08 -07:00
} ;
/* Only deals with one type of droid being selected!!!! */
/* We'll have to make it assesss which selection is to be dominant in the case
of multiple selections */
2007-11-20 14:18:17 -08:00
static SELECTION_TYPE establishSelection ( UDWORD selectedPlayer )
2007-06-28 10:47:08 -07:00
{
2012-12-30 04:24:12 -08:00
DROID * psDominant = NULL ;
UBYTE CurrWeight = UBYTE_MAX ;
bool atLeastOne = false ;
SELECTION_TYPE selectionClass = SC_INVALID ;
2007-06-28 10:47:08 -07:00
2012-12-30 04:24:12 -08:00
for ( DROID * psDroid = apsDroidLists [ selectedPlayer ] ; psDroid ; psDroid = psDroid - > psNext )
2007-06-28 10:47:08 -07:00
{
// This works, uses the DroidSelectionWeights[] table to priorities the different
// droid types and find the dominant selection.
if ( psDroid - > selected ) {
2006-08-23 05:58:48 -07:00
ASSERT ( psDroid - > droidType < NUM_DROID_WEIGHTS ,
" establishSelection : droidType exceeds NUM_DROID_WEIGHTS " ) ;
2007-06-28 10:47:08 -07:00
if ( DroidSelectionWeights [ psDroid - > droidType ] < CurrWeight ) {
2013-10-05 09:22:04 -07:00
atLeastOne = true ;
2007-06-28 10:47:08 -07:00
CurrWeight = DroidSelectionWeights [ psDroid - > droidType ] ;
psDominant = psDroid ;
}
}
}
if ( atLeastOne )
{
psDominantSelected = psDominant ;
switch ( psDominant - > droidType )
{
case DROID_WEAPON :
if ( proj_Direct ( asWeaponStats + psDominant - > asWeaps [ 0 ] . nStat ) )
{
selectionClass = SC_DROID_DIRECT ;
}
else
{
selectionClass = SC_DROID_INDIRECT ;
}
break ;
case DROID_PERSON :
selectionClass = SC_DROID_DIRECT ;
break ;
case DROID_CYBORG :
case DROID_CYBORG_SUPER :
selectionClass = SC_DROID_DIRECT ;
break ;
case DROID_TRANSPORTER :
2012-02-25 16:21:29 -08:00
case DROID_SUPERTRANSPORTER :
2007-06-28 10:47:08 -07:00
//can remove this is NEVER going to select the Transporter to move
2007-05-29 19:06:46 -07:00
//Never say Never!! cos here we go in multiPlayer!!
2007-06-28 10:47:08 -07:00
selectionClass = SC_DROID_TRANSPORTER ;
break ;
case DROID_SENSOR :
selectionClass = SC_DROID_SENSOR ;
break ;
case DROID_ECM :
selectionClass = SC_DROID_ECM ;
break ;
case DROID_CONSTRUCT :
2007-05-29 19:06:46 -07:00
case DROID_CYBORG_CONSTRUCT :
2012-03-01 19:15:51 -08:00
if ( intDemolishSelectMode ( ) )
{
return SC_DROID_DEMOLISH ;
}
2010-05-02 09:27:26 -07:00
selectionClass = SC_DROID_CONSTRUCT ;
2007-06-28 10:47:08 -07:00
break ;
case DROID_COMMAND :
selectionClass = SC_DROID_COMMAND ;
break ;
case DROID_REPAIR :
2007-05-29 19:06:46 -07:00
case DROID_CYBORG_REPAIR :
2007-06-28 10:47:08 -07:00
selectionClass = SC_DROID_REPAIR ;
break ;
2006-05-27 09:37:17 -07:00
default :
2007-06-14 13:59:04 -07:00
ASSERT ( ! " unknown droid type " , " Weirdy droid type on what you've clicked on!!! " ) ;
2007-06-28 10:47:08 -07:00
break ;
}
}
return ( selectionClass ) ;
}
/* Just returns true if the building's present body points aren't 100 percent */
2011-03-12 17:32:15 -08:00
static bool buildingDamaged ( STRUCTURE * psStructure )
2007-06-28 10:47:08 -07:00
{
2010-07-27 09:11:04 -07:00
return psStructure - > body < structureBody ( psStructure ) ;
2007-06-28 10:47:08 -07:00
}
/*Looks through the list of selected players droids to see if one is a repair droid*/
2011-03-12 17:32:15 -08:00
bool repairDroidSelected ( UDWORD player )
2007-06-28 10:47:08 -07:00
{
DROID * psCurr ;
for ( psCurr = apsDroidLists [ player ] ; psCurr ! = NULL ; psCurr = psCurr - > psNext )
{
2007-05-29 19:06:46 -07:00
if ( psCurr - > selected & & (
psCurr - > droidType = = DROID_REPAIR | |
psCurr - > droidType = = DROID_CYBORG_REPAIR ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
}
//didn't find one...
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
/*Looks through the list of selected players droids to see if one is a VTOL droid*/
2011-03-12 17:32:15 -08:00
bool vtolDroidSelected ( UDWORD player )
2007-06-28 10:47:08 -07:00
{
DROID * psCurr ;
for ( psCurr = apsDroidLists [ player ] ; psCurr ! = NULL ; psCurr = psCurr - > psNext )
{
2008-07-07 03:15:00 -07:00
if ( psCurr - > selected & & isVtolDroid ( psCurr ) )
2007-06-28 10:47:08 -07:00
{
// horrible hack to note one of the selected vtols
psSelectedVtol = psCurr ;
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
}
//didn't find one...
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
/*Looks through the list of selected players droids to see if any is selected*/
2011-03-12 17:32:15 -08:00
bool anyDroidSelected ( UDWORD player )
2007-06-28 10:47:08 -07:00
{
DROID * psCurr ;
for ( psCurr = apsDroidLists [ player ] ; psCurr ! = NULL ; psCurr = psCurr - > psNext )
{
if ( psCurr - > selected )
{
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
}
//didn't find one...
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
/*Looks through the list of selected players droids to see if one is a cyborg droid*/
2011-03-12 17:32:15 -08:00
bool cyborgDroidSelected ( UDWORD player )
2007-06-28 10:47:08 -07:00
{
DROID * psCurr ;
for ( psCurr = apsDroidLists [ player ] ; psCurr ! = NULL ; psCurr = psCurr - > psNext )
{
2007-02-10 08:39:39 -08:00
if ( psCurr - > selected & & cyborgDroid ( psCurr ) )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
return true ;
2007-06-28 10:47:08 -07:00
}
}
//didn't find one...
2008-03-24 09:51:17 -07:00
return false ;
2007-06-28 10:47:08 -07:00
}
/* Clear the selection flag for a player */
2012-12-30 02:58:45 -08:00
void clearSel ( )
2007-06-28 10:47:08 -07:00
{
DROID * psCurrDroid ;
STRUCTURE * psStruct ;
FLAG_POSITION * psFlagPos ;
2012-12-30 02:58:45 -08:00
for ( psCurrDroid = apsDroidLists [ selectedPlayer ] ; psCurrDroid ; psCurrDroid = psCurrDroid - > psNext )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
psCurrDroid - > selected = false ;
2007-06-28 10:47:08 -07:00
}
2012-12-30 02:58:45 -08:00
for ( psStruct = apsStructLists [ selectedPlayer ] ; psStruct ; psStruct = psStruct - > psNext )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
psStruct - > selected = false ;
2007-06-28 10:47:08 -07:00
}
2009-03-12 02:25:29 -07:00
bLasSatStruct = false ;
2007-06-28 10:47:08 -07:00
//clear the Deliv Point if one
2012-12-30 02:58:45 -08:00
for ( psFlagPos = apsFlagPosLists [ selectedPlayer ] ; psFlagPos ; psFlagPos = psFlagPos - > psNext )
2007-06-28 10:47:08 -07:00
{
2008-03-24 09:51:17 -07:00
psFlagPos - > selected = false ;
2007-06-28 10:47:08 -07:00
}
setSelectedGroup ( UBYTE_MAX ) ;
setSelectedCommander ( UBYTE_MAX ) ;
intRefreshScreen ( ) ;
2012-12-30 02:58:45 -08:00
triggerEventSelected ( ) ;
2007-06-28 10:47:08 -07:00
}
// Clear the selection and stop driver mode.
//
2012-12-30 02:58:45 -08:00
void clearSelection ( )
2007-06-28 10:47:08 -07:00
{
StopDriverMode ( ) ; // Cancel driver mode ( if active ).
clearSel ( ) ;
}
//access function for bSensorAssigned variable
void setSensorAssigned ( void )
{
2008-03-24 09:51:17 -07:00
bSensorAssigned = true ;
2007-06-28 10:47:08 -07:00
}
2012-06-21 15:34:04 -07:00
/* Initialise the display system */
bool dispInitialise ( void )
{
flagReposVarsValid = false ;
return true ;
}