Merge remote branch 'origin/master' into newnet

Conflicts:
	lib/framework/trig.c
	lib/netplay/netplay.c
	src/pointtree.h
master
Cyp 2010-03-10 22:16:40 +01:00
commit 85315eb568
41 changed files with 202 additions and 136 deletions

View File

@ -1,6 +1,9 @@
#pragma debug(on)
#ifdef FOG_ENABLED
varying float vertexDistance;
#endif
uniform sampler2D Texture0;
uniform sampler2D Texture1;
uniform vec4 teamcolour;
@ -14,12 +17,14 @@ void main(void)
mask = texture2D(Texture1, gl_TexCoord[0].st);
// Apply color using "Merge grain" within tcmask
colour = (colour + (teamcolour - 0.5) * mask.a) * gl_Color;
gl_FragColor = (colour + (teamcolour - 0.5) * mask.a) * gl_Color;
#ifdef FOG_ENABLED
// Calculate linear fog
float fogFactor = (gl_Fog.end - vertexDistance) / (gl_Fog.end - gl_Fog.start);
fogFactor = clamp(fogFactor, 0.0, 1.0);
// Return fragment color
gl_FragColor = mix(gl_Fog.color, colour, fogFactor);
gl_FragColor = mix(gl_Fog.color, gl_FragColor, fogFactor);
#endif
}

View File

@ -1,6 +1,8 @@
#pragma debug(on)
#ifdef FOG_ENABLED
varying float vertexDistance;
#endif
void main(void)
{
@ -15,6 +17,8 @@ void main(void)
// Use "magic" fixed routine while using GLSL < 1.30
gl_Position = ftransform();
#ifdef FOG_ENABLED
// Remember vertex distance
vertexDistance = gl_Position.z;
#endif
}

View File

@ -5,13 +5,13 @@ Superweapon,Level All,10,50,100,1,5,9999,GNLMG1.PIE,TRLMG1.PIE,FXLMgun.PIE,FXTra
SpyTurret01,Level All,75,375,0,0,0,999,GNHECM3.PIE,TRHECM3.PIE,FXLRocPd.PIE,FXMflare.PIE,FXMPExp.PIE,FXMPExp.PIE,FXSSplsh.PIE,0,256,384,30,100,10,0,0,0,1,0,0,0,0,0,0,0,0,1200,0,NO,KINETIC,ELECTRONIC,DIRECT,ANTI PERSONNEL,180,90,-60,YES,YES,0,0,NO,100,0,0,0,0
Rocket-VTOL-Pod,Level All,75,375,200,1,10,5,GNLRCKTP.PIE,TRLRCKTP.PIE,FXLRocPd.PIE,FXMflare.PIE,FXMPExp.PIE,FXMPExp.PIE,FXSSplsh.PIE,0,640,960,50,30,5,2,0,0,50,0,0,0,0,0,0,10,10,1500,20,YES,KINETIC,ROCKET,DIRECT,ANTI TANK,180,20,-60,YES,YES,10,128,YES,25,100,4,1,0
Rocket-VTOL-LtA-T,Level All,100,500,250,1,10,5,GNMRCKTA.PIE,TRMRCKTA.PIE,FXMRocAt.PIE,FXMPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,120,240,0,0,0,0,0,0,0,10,1200,20,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI AIRCRAFT,180,90,-60,YES,NO,0,128,YES,50,100,1,1,0
Rocket-VTOL-HvyA-T,Level All,250,1250,750,1,10,5,Gnmrcktb.PIE,Trmrcktb.PIE,FXMRocAt.PIE,FXMPLME.PIE,FXMExp.PIE,FXMExp.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,160,375,0,0,0,0,0,0,0,10,1000,60,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI AIRCRAFT,180,0,-60,YES,NO,0,128,YES,75,100,1,1,0
Rocket-VTOL-HvyA-T,Level All,250,1250,750,1,10,5,Gnmrcktb.PIE,Trmrcktb.PIE,FXMRocAt.PIE,FXMPLME.PIE,FXMExp.PIE,FXMExp.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,160,375,0,0,0,0,0,0,0,10,1000,60,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI AIRCRAFT,180,90,-60,YES,NO,0,128,YES,75,100,1,1,0
Rocket-VTOL-BB,Level All,150,750,750,1,10,5,Gnmrktbb.PIE,TRMRKTBB.PIE,FXLRocPd.PIE,FXSPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,50,70,200,2,0,0,180,0,0,0,0,0,0,10,10,1200,20,YES,KINETIC,ROCKET,DIRECT,BUNKER BUSTER,180,20,-60,YES,NO,0,128,YES,25,0,1,1,0
Rocket-Pod,Level All,75,375,200,1,10,5,GNLRCKTP.PIE,TRLRCKTP.PIE,FXLRocPd.PIE,FXMflare.PIE,FXMPExp.PIE,FXMPExp.PIE,FXSSplsh.PIE,0,640,960,50,30,10,2,0,0,20,0,0,0,0,0,0,10,10,1500,20,YES,KINETIC,ROCKET,DIRECT,ANTI TANK,180,90,-60,YES,YES,10,128,YES,25,0,0,1,0
Rocket-MRL,Level All,100,500,250,1,10,5,GNMRCKT.PIE,TRMRCKT.PIE,FXMRoc.PIE,FXMflare.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,384,960,40,50,1,2,8,150,30,16,100,30,0,0,0,0,10,1200,20,YES,KINETIC,ROCKET,INDIRECT,ARTILLERY ROUND,180,90,-60,YES,YES,0,128,YES,25,0,0,1,0
Rocket-LtA-T,Level All,100,500,250,1,10,5,GNMRCKTA.PIE,TRMRCKTA.PIE,FXMRocAt.PIE,FXMPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,120,160,0,0,0,0,0,0,0,10,1200,20,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI TANK,180,90,-60,YES,NO,0,128,YES,50,0,0,1,0
Rocket-IDF,Level All,300,1500,10000,1,10,5,GNHRCKT.PIE,TRHRCKT.PIE,FXLRocPd.PIE,FXHPLME.PIE,FXMNExp.PIE,FXMNExp.PIE,FXSSplsh.PIE,0,1024,11000,70,80,1,2,6,600,100,64,99,50,0,0,0,0,0,1000,10,NO,KINETIC,SLOW ROCKET,INDIRECT,ARTILLERY ROUND,0,90,-60,YES,NO,0,640,YES,50,0,0,1,0
Rocket-HvyA-T,Level All,250,1250,250,1,10,5,Gnmrcktb.pie,Trmrcktb.pie,FXMRocAt.PIE,FXMPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,160,250,0,0,0,0,0,0,0,10,1000,60,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI TANK,180,90,0,YES,NO,0,128,YES,75,0,0,1,0
Rocket-HvyA-T,Level All,250,1250,250,1,10,5,Gnmrcktb.pie,Trmrcktb.pie,FXMRocAt.PIE,FXMPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,50,60,1,2,2,160,250,0,0,0,0,0,0,0,10,1000,60,YES,KINETIC,SLOW ROCKET,DIRECT,ANTI TANK,180,90,-60,YES,NO,0,128,YES,75,0,0,1,0
Rocket-BB,Level All,150,750,250,1,10,5,Gnmrktbb.PIE,TRMRKTBB.PIE,FXLRocPd.PIE,FXSPLME.PIE,FXGRDexl.PIE,FXGRDexl.PIE,FXSSplsh.PIE,0,512,1152,60,70,200,2,0,0,125,0,0,0,0,0,0,10,10,1200,20,YES,KINETIC,SLOW ROCKET,DIRECT,BUNKER BUSTER,180,90,-60,YES,NO,0,128,YES,25,0,0,1,0
RailGun3Mk1,Level Three,400,1600,5000,1,120,750,GNHGSS.PIE,TRHGSS.PIE,FXHGauss.PIE,FXGammoH.PIE,Fxflech2.PIE,Fxflech2.PIE,FXVLSWav.PIE,0,1024,2048,80,70,80,1,0,0,300,0,50,30,0,0,0,10,10,900,20,YES,KINETIC,GAUSS,DIRECT,ANTI TANK,180,90,-60,YES,NO,100,0,YES,150,0,0,1,0
RailGun2Mk1,Level Three,300,1200,2000,1,80,500,GNMGSS.PIE,TRMGSS.PIE,FXMGauss.PIE,FXGammoM.PIE,Fxflech2.PIE,Fxflech2.PIE,FXMSWave.PIE,0,768,1536,80,70,60,1,0,0,200,0,0,0,0,0,0,0,0,1100,20,YES,KINETIC,GAUSS,DIRECT,ANTI TANK,180,90,-60,YES,NO,0,0,YES,100,0,0,1,0

View File

@ -17,7 +17,7 @@ extern "C" {
/* --- */
#include <SDL.h>
#include <SDL/SDL.h>
/* --------- Definitions */

View File

@ -24,7 +24,7 @@
#ifndef __INCLUDED_LIB_FRAMEWORK_CURSORS_H__
#define __INCLUDED_LIB_FRAMEWORK_CURSORS_H__
#include <SDL_mouse.h>
#include <SDL/SDL_mouse.h>
#ifdef __cplusplus
extern "C"

View File

@ -278,7 +278,7 @@ void inputHandleKeyEvent(SDL_KeyboardEvent * keyEvent)
break;
}
debug( LOG_INPUT, "Key Code (pressed): 0x%x, %d, [%c] SDLkey=[%s]", vk, vk, (vk < 128) && (vk > 31) ? (char) vk : '?' , SDL_GetKeyName(keyCodeToSDLKey(keyEvent->keysym.sym)));
debug( LOG_INPUT, "Key Code (pressed): 0x%x, %d, [%c] SDLkey=[%s]", vk, vk, (vk < 128) && (vk > 31) ? (char) vk : '?' , SDL_GetKeyName(keyCodeToSDLKey((KEY_CODE)keyEvent->keysym.sym)));
if (unicode < 32)
{
unicode = 0;

View File

@ -30,7 +30,7 @@
#error Framework header files MUST be included from Frame.h ONLY.
#endif
#include <SDL.h>
#include <SDL/SDL.h>
#include "types.h"
#include "lib/framework/utf.h"

View File

@ -91,8 +91,6 @@ extern "C"
}
#ifdef __cplusplus
extern "C"
{
}
#endif //__cplusplus

View File

@ -27,15 +27,15 @@
/* Allow frame header files to be singly included */
#define FRAME_LIB_INCLUDE
#include "types.h"
#include "trig.h"
#include "crc.h"
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include "types.h"
#include "trig.h"
#include "crc.h"
static uint16_t trigSinTable[0x4001];
static uint16_t trigAtanTable[0x2001];

View File

@ -28,9 +28,9 @@
#include <limits.h>
#include <ctype.h>
#ifdef WZ_C99
#if defined WZ_C99 || defined __cplusplus
/* Compilers that have support for C99 have all values below defined in stdint.h */
# include <stdint.h>
# include <inttypes.h>
#else
// Defines C99 types for C99 incompatible compilers (e.g. MSVC)
#include <SDL_stdinc.h>

View File

@ -593,5 +593,11 @@
# define va_copy(dest, src) (void)((dest) = (src))
#endif // !WZ_C99 && !va_copy
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
#endif
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif
#endif /* WZGLOBAL_H */

View File

@ -32,6 +32,7 @@
/***************************************************************************/
#include "lib/framework/frame.h"
#include "lib/framework/vector.h"
#include "ivisdef.h"
#include "ivispatch.h"
@ -52,7 +53,7 @@
//Render style flags for all pie draw functions
#define pie_TRANSLUCENT 0x2
#define pie_ADDITIVE 0x4
#define pie_NO_BILINEAR 0x8
#define pie_FORCE_FOG 0x8
#define pie_HEIGHT_SCALED 0x10
#define pie_RAISE 0x20
#define pie_BUTTON 0x40

View File

@ -32,8 +32,6 @@
/***************************************************************************/
#include <SDL/SDL_opengl.h>
#include "lib/framework/frame.h"
#include "piedef.h"
@ -91,6 +89,7 @@ typedef enum
{
SHADER_NONE,
SHADER_TCMASK,
SHADER_TCMASK_FOGGED,
SHADER_MAX
} SHADER_MODE;

View File

@ -21,11 +21,6 @@
#define _tex_
#include "png_util.h"
#if defined __APPLE__ && defined __MACH__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
//*************************************************************************
@ -44,7 +39,7 @@
typedef struct
{
char name[iV_TEXNAME_MAX];
GLuint id;
uint32_t id;
} iTexPage;
//*************************************************************************

View File

@ -308,9 +308,8 @@ void pie_DownLoadRadar(UDWORD *buffer, int width, int height)
void pie_RenderRadar(int x, int y, int width, int height)
{
pie_SetTexturePage(radarTexture);
pie_SetRendMode(REND_OPAQUE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
pie_SetRendMode(REND_ALPHA);
glColor4ubv(WZCOL_WHITE.vector);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(0, 0); glVertex2f(x, y);

View File

@ -142,17 +142,26 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
pie_SetAlphaTest(true);
/* Set fog status */
if (!(pieFlag & pie_FORCE_FOG) &&
(pieFlag & pie_ADDITIVE || pieFlag & pie_TRANSLUCENT || pieFlag & pie_BUTTON))
{
pie_SetFogStatus(false);
}
else
{
pie_SetFogStatus(true);
}
/* Set tranlucency */
if (pieFlag & pie_ADDITIVE)
{ //Assume also translucent
pie_SetFogStatus(false);
{
pie_SetRendMode(REND_ADDITIVE);
colour.byte.a = (UBYTE)pieFlagData;
light = false;
}
else if (pieFlag & pie_TRANSLUCENT)
{
pie_SetFogStatus(false);
pie_SetRendMode(REND_ALPHA);
colour.byte.a = (UBYTE)pieFlagData;
light = false;
@ -161,13 +170,8 @@ static void pie_Draw3DShape2(iIMDShape *shape, int frame, PIELIGHT colour, PIELI
{
if (pieFlag & pie_BUTTON)
{
pie_SetFogStatus(false);
pie_SetDepthBufferStatus(DEPTH_CMP_LEQ_WRT_ON);
}
else
{
pie_SetFogStatus(true);
}
pie_SetRendMode(REND_OPAQUE);
}
@ -766,13 +770,12 @@ static void pie_DrawShadows(void)
pie_ShadowDrawLoop();
}
pie_SetRendMode(REND_ALPHA);
glEnable(GL_CULL_FACE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glStencilMask(~0);
glStencilFunc(GL_LESS, 0, ~0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0, 0, 0, 0.5);
pie_PerspectiveEnd();
@ -786,7 +789,7 @@ static void pie_DrawShadows(void)
glEnd();
pie_PerspectiveBegin();
glDisable(GL_BLEND);
pie_SetRendMode(REND_OPAQUE);
glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

View File

@ -130,8 +130,7 @@ void pie_DrawSkybox(float scale, int u, int v, int w, int h)
glColor4ub(0xFF,0xFF,0xFF,0xFF);
// enable alpha
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
pie_SetRendMode(REND_ALPHA);
// for the nice blend of the sky with the fog
glDisable(GL_ALPHA_TEST);

View File

@ -27,6 +27,7 @@
#include <SDL.h>
#include <SDL_mouse.h>
#include <physfs.h>
#include <SDL/SDL_opengl.h>
#include "lib/ivis_common/piestate.h"
#include "lib/ivis_common/piedef.h"
@ -76,7 +77,7 @@ static char *readShaderBuf(const char *name)
}
// Retrieve shader compilation errors
static void printShaderInfoLog(GLuint shader)
static void printShaderInfoLog(code_part part, GLuint shader)
{
GLint infologLen = 0;
@ -87,13 +88,13 @@ static void printShaderInfoLog(GLuint shader)
GLchar *infoLog = (GLchar *)malloc(infologLen);
glGetShaderInfoLog(shader, infologLen, &charsWritten, infoLog);
debug(LOG_ERROR, "Shader info log: %s", infoLog);
debug(part, "Shader info log: %s", infoLog);
free(infoLog);
}
}
// Retrieve shader linkage errors
static void printProgramInfoLog(GLuint program)
static void printProgramInfoLog(code_part part, GLuint program)
{
GLint infologLen = 0;
@ -104,30 +105,34 @@ static void printProgramInfoLog(GLuint program)
GLchar *infoLog = (GLchar *)malloc(infologLen);
glGetProgramInfoLog(program, infologLen, &charsWritten, infoLog);
debug(LOG_ERROR, "Program info log: %s", infoLog);
debug(part, "Program info log: %s", infoLog);
free(infoLog);
}
}
// Read/compile/link shaders
static bool loadShaders(GLuint *program, const char *vertexPath, const char *fragmentPath)
static bool loadShaders(GLuint *program, const char *definitions,
const char *vertexPath, const char *fragmentPath)
{
GLint status;
bool success = true; // Assume overall success
char *buffer;
*program = glCreateProgram();
char *buffer[2];
ASSERT_OR_RETURN(false, *program != 0, "Could not create shader program");
*program = glCreateProgram();
ASSERT_OR_RETURN(false, definitions != NULL, "Null in preprocessor definitions!");
ASSERT_OR_RETURN(false, *program, "Could not create shader program!");
*buffer = (char *)definitions;
if (vertexPath)
{
success = false; // Assume failure before reading shader file
if ((buffer = readShaderBuf(vertexPath)))
if ((*(buffer + 1) = readShaderBuf(vertexPath)))
{
GLuint shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(shader, 1, (const char **)&buffer, NULL);
glShaderSource(shader, 2, (const char **)buffer, NULL);
glCompileShader(shader);
// Check for compilation errors
@ -135,15 +140,16 @@ static bool loadShaders(GLuint *program, const char *vertexPath, const char *fra
if (!status)
{
debug(LOG_ERROR, "Vertex shader compilation has failed [%s]", vertexPath);
printShaderInfoLog(shader);
printShaderInfoLog(LOG_ERROR, shader);
}
else
{
printShaderInfoLog(LOG_3D, shader);
glAttachShader(*program, shader);
success = true;
}
free(buffer);
free(*(buffer + 1));
}
}
@ -151,11 +157,11 @@ static bool loadShaders(GLuint *program, const char *vertexPath, const char *fra
{
success = false; // Assume failure before reading shader file
if ((buffer = readShaderBuf(fragmentPath)))
if ((*(buffer + 1) = readShaderBuf(fragmentPath)))
{
GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(shader, 1, (const char **)&buffer, NULL);
glShaderSource(shader, 2, (const char **)buffer, NULL);
glCompileShader(shader);
// Check for compilation errors
@ -163,15 +169,16 @@ static bool loadShaders(GLuint *program, const char *vertexPath, const char *fra
if (!status)
{
debug(LOG_ERROR, "Fragment shader compilation has failed [%s]", fragmentPath);
printShaderInfoLog(shader);
printShaderInfoLog(LOG_ERROR, shader);
}
else
{
printShaderInfoLog(LOG_3D, shader);
glAttachShader(*program, shader);
success = true;
}
free(buffer);
free(*(buffer + 1));
}
}
@ -184,9 +191,13 @@ static bool loadShaders(GLuint *program, const char *vertexPath, const char *fra
if (!status)
{
debug(LOG_ERROR, "Shader program linkage has failed [%s, %s]", vertexPath, fragmentPath);
printProgramInfoLog(*program);
printProgramInfoLog(LOG_ERROR, *program);
success = false;
}
else
{
printProgramInfoLog(LOG_3D, *program);
}
}
return success;
@ -204,11 +215,18 @@ bool pie_LoadShaders()
shaderProgram[SHADER_NONE] = 0;
// TCMask shader
debug(LOG_3D, "Loading shaders: SHADER_TCMASK");
if (!loadShaders(&program, "shaders/tcmask.vert", "shaders/tcmask.frag"))
debug(LOG_3D, "Loading shader: SHADER_TCMASK");
if (!loadShaders(&program, "",
"shaders/tcmask.vert", "shaders/tcmask.frag"))
return false;
shaderProgram[SHADER_TCMASK] = program;
debug(LOG_3D, "Loading shader: SHADER_TCMASK_FOGGED");
if (!loadShaders(&program, "#define FOG_ENABLED\n",
"shaders/tcmask.vert", "shaders/tcmask.frag"))
return false;
shaderProgram[SHADER_TCMASK_FOGGED] = program;
// Good to go
shadersAvailable = true;
return true;
@ -247,7 +265,15 @@ void pie_ActivateShader_TCMask(PIELIGHT teamcolour, SDWORD maskpage)
if (!shadersAvailable)
return;
shaderProgram = pie_SetShader(SHADER_TCMASK);
// Check if fog is enabled
if (rendStates.fog)
{
shaderProgram = pie_SetShader(SHADER_TCMASK_FOGGED);
}
else
{
shaderProgram = pie_SetShader(SHADER_TCMASK);
}
loc = glGetUniformLocation(shaderProgram, "Texture0");
glUniform1i(loc, 0);

View File

@ -2409,6 +2409,10 @@ static BOOL NETprocessSystemMessage(NETQUEUE playerQueue, uint8_t type)
case NET_PLAYER_INFO:
{
uint32_t index;
int32_t colour = 0;
int32_t position = 0;
int32_t team = 0;
uint32_t hostPlayer = 0;
NETbeginDecode(playerQueue, NET_PLAYER_INFO);
// Retrieve the player's ID
@ -2434,18 +2438,22 @@ static BOOL NETprocessSystemMessage(NETQUEUE playerQueue, uint8_t type)
NETbool(&NetPlay.players[index].kick);
NETstring(NetPlay.players[index].name, sizeof(NetPlay.players[index].name));
NETuint32_t(&NetPlay.players[index].heartattacktime);
NETint32_t(&NetPlay.players[index].colour);
NETint32_t(&NetPlay.players[index].position);
NETint32_t(&NetPlay.players[index].team);
NETint32_t(&colour);
NETint32_t(&position);
NETint32_t(&team);
NETbool(&NetPlay.players[index].ready);
NETuint32_t(&NetPlay.hostPlayer); // Does this make sense at all?
NETuint32_t(&hostPlayer);
NETend();
if (NetPlay.hostPlayer != NET_HOST_ONLY)
// Don't let anyone except the host change these, otherwise it will end up inconsistent at some point, and the game gets really messed up.
if (playerQueue.index == NetPlay.hostPlayer)
{
// Exactly what was the point of letting anyone change the host? This codebase is confusing.
debug(LOG_ERROR, "MSG_PLAYER_INFO: Player %d thinks that player %d is the host...", playerQueue.index, NetPlay.hostPlayer);
NetPlay.hostPlayer = NET_HOST_ONLY;
NetPlay.players[index].colour = colour;
NetPlay.players[index].position = position;
NetPlay.players[index].team = team;
//NetPlay.hostPlayer = hostPlayer; // Huh?
}
debug(LOG_NET, "Receiving MSG_PLAYER_INFO for player %u (%s)", (unsigned int)index, NetPlay.players[index].allocated ? "human" : "AI");
// update the color to the local array
setPlayerColour(index, NetPlay.players[index].colour);
@ -3329,11 +3337,14 @@ static void NETallowJoining(void)
// Send info about players to newcomer.
for (j = 0; j < MAX_CONNECTED_PLAYERS; ++j)
{
if (NetPlay.players[j].allocated && index != j)
if (index != j) // We will broadcast the index == j case.
{
NETbeginEncode(NETnetQueue(index), NET_PLAYER_JOINED);
NETuint8_t(&j);
NETend();
if (NetPlay.players[j].allocated)
{
NETbeginEncode(NETnetQueue(index), NET_PLAYER_JOINED);
NETuint8_t(&j);
NETend();
}
NETSendPlayerInfoTo(j, index);
}
}

View File

@ -59,6 +59,7 @@ static const char *pEndBuffer = NULL;
static SDWORD playerIndex;
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
if (pInputBuffer != pEndBuffer) { \
buf[0] = *(pInputBuffer++); result = 1; \

View File

@ -26,6 +26,8 @@
#ifndef _codeprint_h
#define _codeprint_h
#include "lib/script/interpreter.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -78,6 +78,7 @@ static unsigned int scr_num_macros; /* Number of macros defined so far */
static int scr_macro_stack_ptr; /* Pointer to the current flex macro input buffer */
static char *pScrMacroBuffer[MAX_SCR_MACRO_DEPTH];
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
{ \
if (PHYSFS_eof(pScrInputFiles[scr_include_stack_ptr])) \
@ -478,7 +479,7 @@ init return INITIALISE;
link return LINK;
ref return REF;
return return RET;
function return FUNCTION;
function return lexFUNCTION;
"("int")"|"("INT")" { RULE(yytext); return TO_INT_CAST; }
"("float")"|"("FLOAT")" { RULE(yytext); return TO_FLOAT_CAST; }
public { scr_lval.stype = ST_PUBLIC; return STORAGE; }

View File

@ -1764,7 +1764,7 @@ static void scriptStoreVarTypes(VAR_SYMBOL *psVar)
VAR_IDENT_DECL *videcl;
}
/* key words */
%token FUNCTION
%token lexFUNCTION
%token TRIGGER
%token EVENT
%token WAIT
@ -2444,10 +2444,10 @@ event_subdecl: EVENT IDENT
;
function_def: FUNCTION TYPE function_type
function_def: lexFUNCTION TYPE function_type
{
RULE("function_def: FUNCTION TYPE function_type");
RULE("function_def: lexFUNCTION TYPE function_type");
psCurEvent = $3;
@ -2473,11 +2473,11 @@ function_type: VOID_FUNC_CUST
;
/* function declaration rules */
func_subdecl: FUNCTION TYPE IDENT
func_subdecl: lexFUNCTION TYPE IDENT
{
EVENT_SYMBOL *psEvent;
RULE("func_subdecl: FUNCTION TYPE IDENT");
RULE("func_subdecl: lexFUNCTION TYPE IDENT");
/* allow local vars to have the same names as global vars (don't check global vars) */
localVariableDef = true;
@ -2494,17 +2494,17 @@ func_subdecl: FUNCTION TYPE IDENT
$$ = psEvent;
//debug(LOG_SCRIPT, "END func_subdecl:FUNCTION TYPE IDENT. ");
//debug(LOG_SCRIPT, "END func_subdecl:lexFUNCTION TYPE IDENT. ");
}
;
/* void function declaration rules */
void_func_subdecl: FUNCTION _VOID IDENT /* declaration of a function */
void_func_subdecl: lexFUNCTION _VOID IDENT /* declaration of a function */
{
EVENT_SYMBOL *psEvent;
RULE("void_func_subdecl: FUNCTION _VOID IDENT");
RULE("void_func_subdecl: lexFUNCTION _VOID IDENT");
/* allow local vars to have the same names as global vars (don't check global vars) */
localVariableDef = true;
@ -2521,13 +2521,13 @@ void_func_subdecl: FUNCTION _VOID IDENT /* declaration of a function */
$$ = psEvent;
//debug(LOG_SCRIPT, "END func_subdecl:FUNCTION TYPE IDENT. ");
//debug(LOG_SCRIPT, "END func_subdecl:lexFUNCTION TYPE IDENT. ");
}
;
void_function_def: FUNCTION _VOID function_type /* definition of a function that was declated before */
void_function_def: lexFUNCTION _VOID function_type /* definition of a function that was declated before */
{
//debug(LOG_SCRIPT, "func_subdecl:FUNCTION EVENT_SYM ");
//debug(LOG_SCRIPT, "func_subdecl:lexFUNCTION EVENT_SYM ");
psCurEvent = $3;
@ -2542,7 +2542,7 @@ void_function_def: FUNCTION _VOID function_type /* definition of a function tha
/* psCurEvent->bFunction = true; */
/* psEvent->retType = $2; */
$$ = $3;
//debug(LOG_SCRIPT, "func_subdecl:FUNCTION EVENT_SYM. ");
//debug(LOG_SCRIPT, "func_subdecl:lexFUNCTION EVENT_SYM. ");
}
;

View File

@ -24,6 +24,8 @@
#ifndef __INCLUDED_LIB_WIDGET_FORM_H__
#define __INCLUDED_LIB_WIDGET_FORM_H__
#include "lib/widget/widget.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -25,6 +25,7 @@
#define __INCLUDED_LIB_WIDGET_TIP_H__
#include "lib/ivis_common/textdraw.h"
#include "lib/widget/widgbase.h"
#ifdef __cplusplus
extern "C"

View File

@ -365,7 +365,7 @@ void renderParticle( ATPART *psPart )
/* Draw it... */
centreX = player.p.x + world_coord(visibleTiles.x / 2);
centreZ = player.p.z + world_coord(visibleTiles.y / 2);
pie_Draw3DShape(psPart->imd, 0, 0, WZCOL_WHITE, WZCOL_BLACK, pie_NO_BILINEAR, 0);
pie_Draw3DShape(psPart->imd, 0, 0, WZCOL_WHITE, WZCOL_BLACK, 0, 0);
iV_MatrixEnd();
}

View File

@ -21,6 +21,8 @@
#ifndef __INCLUDED_SRC_BRIDGE_H__
#define __INCLUDED_SRC_BRIDGE_H__
#include "structuredef.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -24,6 +24,8 @@
#ifndef __INCLUDED_SRC_DATA_H__
#define __INCLUDED_SRC_DATA_H__
#include "lib/framework/types.h"
#ifdef __cplusplus
extern "C"
{
@ -64,7 +66,7 @@ enum {
};
void resetDataHash(void);
UDWORD DataHash[DATA_MAXDATA];
extern uint32_t DataHash[DATA_MAXDATA];
/* Pass all the data loading functions to the framework library */
bool dataInitLoadFuncs(void);

View File

@ -22,6 +22,7 @@
#define __INCLUDED_SRC_DESIGN_H__
#include "lib/widget/widgbase.h"
#include "src/droiddef.h"
#ifdef __cplusplus
extern "C"

View File

@ -212,9 +212,6 @@ static bool mouseScroll = true;
BOOL rotActive = false;
BOOL gameStats = false;
/* Mouse x and y - no point checking them more than once per frame */
Uint16 mouseXPos = OFF_SCREEN, mouseYPos = OFF_SCREEN;
/* Hackety hack hack hack */
SDWORD screenShakeTable[100] =
{
@ -451,10 +448,7 @@ void processInput(void)
BOOL mOverRadar = false;
int WheelZoomIterator;
mouseXPos = mouseX();
mouseYPos = mouseY();
if(radarOnScreen && getHQExists(selectedPlayer) && CoordInRadar(mouseXPos, mouseYPos))
if(radarOnScreen && getHQExists(selectedPlayer) && CoordInRadar(mouseX(), mouseY()))
{
mOverRadar = true;
}
@ -585,8 +579,8 @@ static void CheckFinishedDrag(void)
clearSelection();
}
dragBox3D.status = DRAG_RELEASED;
dragBox3D.x2 = mouseXPos;
dragBox3D.y2 = mouseYPos;
dragBox3D.x2 = mouseX();
dragBox3D.y2 = mouseY();
}
else
{
@ -684,9 +678,9 @@ static void HandleDrag(void)
{
if(!driveModeActive()) {
dragBox3D.x1 = dragX;
dragBox3D.x2 = mouseXPos;
dragBox3D.x2 = mouseX();
dragBox3D.y1 = dragY;
dragBox3D.y2 = mouseYPos;
dragBox3D.y2 = mouseY();
dragBox3D.status = DRAG_DRAGGING;
}
@ -1055,25 +1049,25 @@ void scroll(void)
if (mouseScroll)
{
/* Scroll left */
if (mouseXPos < BOUNDARY_X)
if (mouseX() < BOUNDARY_X)
{
mouseAtLeft = true;
}
/* Scroll right */
if (mouseXPos > (pie_GetVideoBufferWidth() - BOUNDARY_X))
if (mouseX() > (pie_GetVideoBufferWidth() - BOUNDARY_X))
{
mouseAtRight = true;
}
/* Scroll up */
if (mouseYPos < BOUNDARY_Y)
if (mouseY() < BOUNDARY_Y)
{
mouseAtBottom = true;
}
/* Scroll down */
if (mouseYPos > (pie_GetVideoBufferHeight() - BOUNDARY_Y))
if (mouseY() > (pie_GetVideoBufferHeight() - BOUNDARY_Y))
{
mouseAtTop = true;
}
@ -1307,41 +1301,41 @@ void displayWorld(void)
if (mouseDown(MOUSE_RMB) && rotActive)
{
if (abs(mouseXPos - rotX) > 8 || xMoved > 8)
if (abs(mouseX() - rotX) > 8 || xMoved > 8)
{
xMoved += abs(mouseXPos - rotX);
if (mouseXPos < rotX)
xMoved += abs(mouseX() - rotX);
if (mouseX() < rotX)
{
player.r.y = rotInitial + (rotX - mouseXPos)/2 * DEG(1);
player.r.y = rotInitial + (rotX - mouseX())/2 * DEG(1);
}
else
{
player.r.y = rotInitial - (mouseXPos - rotX)/2 * DEG(1);
player.r.y = rotInitial - (mouseX() - rotX)/2 * DEG(1);
}
}
if (abs(mouseYPos - rotY) > 8 || yMoved > 8)
if (abs(mouseY() - rotY) > 8 || yMoved > 8)
{
yMoved += abs(mouseYPos - rotY);
yMoved += abs(mouseY() - rotY);
if (bInvertMouse)
{
if (mouseYPos < rotY)
if (mouseY() < rotY)
{
player.r.x = rotInitialUp + (rotY - mouseYPos)/3 * DEG(1);
player.r.x = rotInitialUp + (rotY - mouseY())/3 * DEG(1);
}
else
{
player.r.x = rotInitialUp - (mouseYPos - rotY)/3 * DEG(1);
player.r.x = rotInitialUp - (mouseY() - rotY)/3 * DEG(1);
}
}
else
{
if(mouseYPos < rotY)
if(mouseY() < rotY)
{
player.r.x = rotInitialUp - (rotY - mouseYPos)/3 * DEG(1);
player.r.x = rotInitialUp - (rotY - mouseY())/3 * DEG(1);
}
else
{
player.r.x = rotInitialUp + (mouseYPos - rotY)/3 * DEG(1);
player.r.x = rotInitialUp + (mouseY() - rotY)/3 * DEG(1);
}
}
if(player.r.x > DEG(360 + MAX_PLAYER_X_ANGLE))
@ -1374,7 +1368,7 @@ void displayWorld(void)
static BOOL mouseInBox(SDWORD x0, SDWORD y0, SDWORD x1, SDWORD y1)
{
return mouseXPos > x0 && mouseXPos < x1 && mouseYPos > y0 && mouseYPos < y1;
return mouseX() > x0 && mouseX() < x1 && mouseY() > y0 && mouseY() < y1;
}
BOOL DrawnInLastFrame(int32_t frame)

View File

@ -35,8 +35,6 @@ extern "C"
/* Initialise the display system */
extern BOOL dispInitialise(void);
extern uint16_t mouseXPos, mouseYPos;
extern void shakeStart(void);
extern void shakeStop(void);

View File

@ -23,6 +23,11 @@
* Originally by Alex McLean & Jeremy Sallis, Pumpkin Studios, EIDOS INTERACTIVE
*/
#include "lib/ivis_opengl/GLee.h"
// Workaround X11 headers #defining Status
#ifdef Status
# undef Status
#endif
#include "lib/framework/frame.h"
#include "lib/framework/math_ext.h"
#include "lib/framework/stdio_ext.h"
@ -1165,7 +1170,7 @@ void renderProjectile(PROJECTILE *psCurr)
}
else
{
pie_Draw3DShape(pIMD, 0, 0, WZCOL_WHITE, WZCOL_BLACK, pie_NO_BILINEAR, 0);
pie_Draw3DShape(pIMD, 0, 0, WZCOL_WHITE, WZCOL_BLACK, 0, 0);
}
iV_MatrixEnd();
@ -1276,7 +1281,7 @@ void renderAnimComponent( const COMPONENT_OBJECT *psObj )
iV_MatrixRotateZ(-psObj->orientation.y);
iV_MatrixRotateX(-psObj->orientation.x);
pie_Draw3DShape(psObj->psShape, 0, iPlayer, brightness, WZCOL_BLACK, pie_NO_BILINEAR|pie_STATIC_SHADOW, 0);
pie_Draw3DShape(psObj->psShape, 0, iPlayer, brightness, WZCOL_BLACK, pie_STATIC_SHADOW, 0);
/* clear stack */
iV_MatrixEnd();
@ -2109,7 +2114,7 @@ void renderStructure(STRUCTURE *psStructure)
}
else
{
pieFlag = pie_TRANSLUCENT;
pieFlag = pie_TRANSLUCENT | pie_FORCE_FOG;
pieFlagData = 255;
}
pie_Draw3DShape(psStructure->pStructureType->pBaseIMD, 0, colour, buildingBrightness, WZCOL_BLACK, pieFlag, pieFlagData);
@ -2687,10 +2692,10 @@ static void drawDragBox( void )
}
// SHURCOOL: Determine the 4 corners of the selection box, and use them for consistent selection box rendering
minX = MIN(dragBox3D.x1, mouseXPos);
maxX = MAX(dragBox3D.x1, mouseXPos);
minY = MIN(dragBox3D.y1, mouseYPos);
maxY = MAX(dragBox3D.y1, mouseYPos);
minX = MIN(dragBox3D.x1, mouseX());
maxX = MAX(dragBox3D.x1, mouseX());
minY = MIN(dragBox3D.y1, mouseY());
maxY = MAX(dragBox3D.y1, mouseY());
// SHURCOOL: Reduce the box in size to produce a (consistent) pulsing inward effect
minX += dragBox3D.pulse / 2;
@ -3546,7 +3551,7 @@ void calcScreenCoords(DROID *psDroid)
*/
static void locateMouse(void)
{
const Vector2i pt = {mouseXPos, mouseYPos};
const Vector2i pt = {mouseX(), mouseY()};
unsigned int i;
int nearestZ = INT_MAX;

View File

@ -24,6 +24,8 @@
#ifndef __INCLUDED_SRC_INTELMAP_H__
#define __INCLUDED_SRC_INTELMAP_H__
#include "messagedef.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -1334,7 +1334,7 @@ void kf_toggleTrapCursor(void)
const char *msg;
bool trap = !war_GetTrapCursor();
war_SetTrapCursor(trap);
SDL_WM_GrabInput(trap);
SDL_WM_GrabInput(trap ? SDL_GRAB_ON : SDL_GRAB_OFF);
sasprintf((char**)&msg, _("Trap cursor %s"), trap ? "ON" : "OFF");
addConsoleMessage(msg, DEFAULT_JUSTIFY, SYSTEM_MESSAGE);
}
@ -2680,11 +2680,11 @@ void kf_ToggleRadarAllyEnemy(void)
void kf_ToggleRadarTerrain(void)
{
radarDrawMode++;
radarDrawMode = (RADAR_DRAW_MODE)(radarDrawMode + 1);
if (radarDrawMode == RADAR_MODE_TERRAIN_SEEN && getRevealStatus())
{
radarDrawMode++; // skip this radar mode for fog of war mode
radarDrawMode = (RADAR_DRAW_MODE)(radarDrawMode + 1); // skip this radar mode for fog of war mode
}
if (radarDrawMode >= NUM_RADAR_MODES)
{

View File

@ -327,7 +327,7 @@ static void displayKeyMap(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, WZ_D
if (psMapping->subKeyCode >= KEY_KP_0 && psMapping->subKeyCode <= KEY_KPENTER)
{
iV_SetTextColour(WZCOL_YELLOW);
ssprintf(sKey, "(numpad)%s", SDL_GetKeyName(psMapping->subKeyCode));
ssprintf(sKey, "(numpad)%s", SDL_GetKeyName((SDLKey)psMapping->subKeyCode));
}
iV_DrawText(sKey, x + 364, y + (psWidget->height / 2) + 3);
}

View File

@ -24,6 +24,9 @@
#ifndef __INCLUDED_SRC_MULTIMENU__
#define __INCLUDED_SRC_MULTIMENU__
#include "lib/widget/widgbase.h"
#include "stringdef.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -105,7 +105,7 @@ static inline void setProjectileSource(PROJECTILE *psProj, BASE_OBJECT *psObj)
static inline void setProjectileDamaged(PROJECTILE *psProj, BASE_OBJECT *psObj)
{
++psProj->psNumDamaged;
psProj->psDamaged = realloc(psProj->psDamaged, psProj->psNumDamaged*sizeof(BASE_OBJECT *));
psProj->psDamaged = (BASE_OBJECT **)realloc(psProj->psDamaged, psProj->psNumDamaged*sizeof(BASE_OBJECT *));
psProj->psDamaged[psProj->psNumDamaged - 1] = psObj;
}

View File

@ -24,6 +24,9 @@
#ifndef __INCLUDED_SRC_SCRIPTOBJ_H__
#define __INCLUDED_SRC_SCRIPTOBJ_H__
#include "lib/framework/types.h"
#include "lib/script/interpreter.h"
#ifdef __cplusplus
extern "C"
{

View File

@ -25,6 +25,7 @@
#define __INCLUDED_SRC_SCRIPTTABS_H__
#include "lib/script/event.h" // needed for _scr_user_types
#include "lib/script/parse.h"
#ifdef __cplusplus
extern "C"

View File

@ -24,6 +24,8 @@
#ifndef __INCLUDED_SRC_SCRIPTVALS_H__
#define __INCLUDED_SRC_SCRIPTVALS_H__
#include "lib/script/interpreter.h"
#include "lib/script/event.h"
#include "basedef.h"
#include <physfs.h>

View File

@ -1243,8 +1243,8 @@ void drawTerrain(void)
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
// additive blending
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
pie_SetRendMode(REND_ADDITIVE);
// only draw colors
glDepthMask(GL_FALSE);
@ -1310,7 +1310,7 @@ void drawTerrain(void)
// select the terrain texture page
pie_SetTexturePage(terrainPage); glError();
// use the alpha to blend
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
pie_SetRendMode(REND_ALPHA);
// and the texture coordinates buffer
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glError();
glEnableClientState( GL_VERTEX_ARRAY ); glError();
@ -1355,7 +1355,7 @@ void drawTerrain(void)
glDisableClientState( GL_VERTEX_ARRAY );
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
pie_SetRendMode(REND_OPAQUE);
glPopAttrib();
}