git-svn-id: https://svn.eduke32.com/eduke32@1631 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2010-05-05 07:31:38 +00:00
parent cda6330cc2
commit e1649b9d0b
6 changed files with 79 additions and 193 deletions

View file

@ -24,7 +24,7 @@ $(OBJ)/osd.$o: $(SRC)/osd.c $(INC)/build.h $(INC)/osd.h $(INC)/compat.h $(INC)/b
$(OBJ)/pragmas.$o: $(SRC)/pragmas.c $(INC)/compat.h $(OBJ)/pragmas.$o: $(SRC)/pragmas.c $(INC)/compat.h
$(OBJ)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/scriptfile.h $(INC)/cache1d.h $(INC)/compat.h $(OBJ)/scriptfile.$o: $(SRC)/scriptfile.c $(INC)/scriptfile.h $(INC)/cache1d.h $(INC)/compat.h
$(OBJ)/sdlayer.$o: $(SRC)/sdlayer.c $(INC)/compat.h $(INC)/sdlayer.h $(INC)/baselayer.h $(INC)/cache1d.h $(INC)/pragmas.h $(INC)/a.h $(INC)/build.h $(INC)/osd.h $(INC)/glbuild.h $(OBJ)/sdlayer.$o: $(SRC)/sdlayer.c $(INC)/compat.h $(INC)/sdlayer.h $(INC)/baselayer.h $(INC)/cache1d.h $(INC)/pragmas.h $(INC)/a.h $(INC)/build.h $(INC)/osd.h $(INC)/glbuild.h
$(OBJ)/winlayer.$o: $(SRC)/winlayer.c $(INC)/compat.h $(INC)/winlayer.h $(INC)/baselayer.h $(INC)/pragmas.h $(INC)/build.h $(INC)/a.h $(INC)/osd.h $(INC)/dxdidf.h $(INC)/glbuild.h $(OBJ)/winlayer.$o: $(SRC)/winlayer.c $(INC)/compat.h $(INC)/winlayer.h $(INC)/baselayer.h $(INC)/pragmas.h $(INC)/build.h $(INC)/a.h $(INC)/osd.h $(INC)/dxdidf.h $(INC)/glbuild.h $(INC)/rawinput.h
$(OBJ)/gtkbits.$o: $(SRC)/gtkbits.c $(INC)/baselayer.h $(INC)/build.h $(INC)/dynamicgtk.h $(OBJ)/gtkbits.$o: $(SRC)/gtkbits.c $(INC)/baselayer.h $(INC)/build.h $(INC)/dynamicgtk.h
$(OBJ)/dynamicgtk.$o: $(SRC)/dynamicgtk.c $(INC)/dynamicgtk.h $(OBJ)/dynamicgtk.$o: $(SRC)/dynamicgtk.c $(INC)/dynamicgtk.h
$(OBJ)/polymer.$o: $(SRC)/polymer.c $(INC)/polymer.h $(INC)/compat.h $(INC)/build.h $(INC)/glbuild.h $(INC)/osd.h $(INC)/pragmas.h $(INC)/mdsprite.h $(INC)/polymost.h $(OBJ)/polymer.$o: $(SRC)/polymer.c $(INC)/polymer.h $(INC)/compat.h $(INC)/build.h $(INC)/glbuild.h $(INC)/osd.h $(INC)/pragmas.h $(INC)/mdsprite.h $(INC)/polymost.h

View file

@ -4,11 +4,6 @@
#include "compat.h" #include "compat.h"
void RI_PollDevices(); void RI_PollDevices();
uint8_t RI_MouseState( uint8_t Button );
int8_t RI_WheelState();
int32_t RI_CaptureInput(int32_t grab, HWND target); int32_t RI_CaptureInput(int32_t grab, HWND target);
#ifndef VK_LBUTTON #ifndef VK_LBUTTON
@ -24,11 +19,5 @@ int32_t RI_CaptureInput(int32_t grab, HWND target);
#define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */ #define VK_MBUTTON 0x04 /* NOT contiguous with L & RBUTTON */
#endif #endif
// mouse states for RI_MouseState
#define BUTTON_PRESSED 0x01
#define BUTTON_RELEASED 0x02
#define BUTTON_HELD 0x03
#endif // rawinput_h__ #endif // rawinput_h__

View file

@ -7,9 +7,7 @@
#include "build.h" #include "build.h"
static BOOL init_done = 0; static BOOL init_done = 0;
static uint8_t KeyboardState[256] = {0}; static uint8_t KeyboardState[256] = {0}; // VKeys
static uint8_t MouseState0[5] = {0};
static uint8_t MouseState1[5] = {0};
static int8_t MWheel = 0; static int8_t MWheel = 0;
extern volatile uint8_t moustat, mousegrab; extern volatile uint8_t moustat, mousegrab;
@ -18,14 +16,12 @@ extern void SetKey(int32_t key, int32_t state);
#define MASK_DOWN (1<<(i<<1)) #define MASK_DOWN (1<<(i<<1))
#define MASK_UP (MASK_DOWN<<1) #define MASK_UP (MASK_DOWN<<1)
#define MouseWheelFakePressTime 50 #define MouseWheelFakePressTime 50
#ifndef GET_RAWINPUT_CODE_WPARAM #ifndef GET_RAWINPUT_CODE_WPARAM
#define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff) #define GET_RAWINPUT_CODE_WPARAM(wParam) ((wParam) & 0xff)
#endif #endif
void RI_ProcessMouse(const RAWMOUSE* rmouse) static inline void RI_ProcessMouse(const RAWMOUSE* rmouse)
{ {
int32_t i, mask; int32_t i, mask;
@ -48,20 +44,16 @@ void RI_ProcessMouse(const RAWMOUSE* rmouse)
for (i = 0, mask = 1; i < 4; i++) for (i = 0, mask = 1; i < 4; i++)
{ {
MouseState1[i] = MouseState0[i];
if (rmouse->usButtonFlags & mask) // button down if (rmouse->usButtonFlags & mask) // button down
{ {
MouseState1[i] = 1;
if (mousepresscallback) if (mousepresscallback)
mousepresscallback(i, MouseState1[i]); mousepresscallback(i, 1);
mouseb |= 1<<i; mouseb |= 1<<i;
} }
else if (rmouse->usButtonFlags & (mask<<1)) // button up else if (rmouse->usButtonFlags & (mask<<1)) // button up
{ {
MouseState1[i] = 0;
if (mousepresscallback) if (mousepresscallback)
mousepresscallback(i, MouseState1[i]); mousepresscallback(i, 0);
mouseb &= ~(1<<i); mouseb &= ~(1<<i);
} }
mask <<= 2; mask <<= 2;
@ -85,10 +77,9 @@ void RI_ProcessMouse(const RAWMOUSE* rmouse)
} }
} }
void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd)
{ {
uint8_t key = rkbd->MakeCode; uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey;
uint8_t VKey = rkbd->VKey;
// for some reason rkbd->MakeCode is wrong for these // for some reason rkbd->MakeCode is wrong for these
// even though rkbd->VKey is right... // even though rkbd->VKey is right...
@ -104,23 +95,19 @@ void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd)
case VK_UP: case VK_UP:
case VK_NUMPAD8: case VK_NUMPAD8:
if (rkbd->Flags & RI_KEY_E0) VKey = VK_UP, key = sc_UpArrow; if (rkbd->Flags & RI_KEY_E0) VKey = VK_UP, key = sc_UpArrow;
else VKey = VK_NUMPAD8, key = sc_kpad_8; else VKey = VK_NUMPAD8, key = sc_kpad_8; break;
break;
case VK_DOWN: case VK_DOWN:
case VK_NUMPAD2: case VK_NUMPAD2:
if (rkbd->Flags & RI_KEY_E0) VKey = VK_DOWN, key = sc_DownArrow; if (rkbd->Flags & RI_KEY_E0) VKey = VK_DOWN, key = sc_DownArrow;
else VKey = VK_NUMPAD2, key = sc_kpad_2; else VKey = VK_NUMPAD2, key = sc_kpad_2; break;
break;
case VK_LEFT: case VK_LEFT:
case VK_NUMPAD4: case VK_NUMPAD4:
if (rkbd->Flags & RI_KEY_E0) VKey = VK_LEFT, key = sc_LeftArrow; if (rkbd->Flags & RI_KEY_E0) VKey = VK_LEFT, key = sc_LeftArrow;
else VKey = VK_NUMPAD4, key = sc_kpad_4; else VKey = VK_NUMPAD4, key = sc_kpad_4; break;
break;
case VK_RIGHT: case VK_RIGHT:
case VK_NUMPAD6: case VK_NUMPAD6:
if (rkbd->Flags & RI_KEY_E0) VKey = VK_RIGHT, key = sc_RightArrow; if (rkbd->Flags & RI_KEY_E0) VKey = VK_RIGHT, key = sc_RightArrow;
else VKey = VK_NUMPAD6, key = sc_kpad_6; else VKey = VK_NUMPAD6, key = sc_kpad_6; break;
break;
case VK_INSERT: case VK_INSERT:
key = sc_Insert; break; key = sc_Insert; break;
case VK_HOME: case VK_HOME:
@ -169,11 +156,6 @@ int32_t RI_CaptureInput(int32_t grab, HWND target)
return (RegisterRawInputDevices(raw, 2, sizeof(raw[0])) == FALSE); return (RegisterRawInputDevices(raw, 2, sizeof(raw[0])) == FALSE);
} }
uint8_t RI_MouseState(uint8_t Button)
{
return ((MouseState0[Button-1] << 1) | MouseState1[Button-1]) & 0x03;
}
void RI_PollDevices() void RI_PollDevices()
{ {
int32_t i; int32_t i;
@ -190,8 +172,6 @@ void RI_PollDevices()
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
KeyboardState[i] = (KeyboardState[i] << 1) | (1 & KeyboardState[i]); KeyboardState[i] = (KeyboardState[i] << 1) | (1 & KeyboardState[i]);
Bmemcpy(MouseState0, MouseState1, sizeof(MouseState0));
MWheel = 0; MWheel = 0;
while (PeekMessage(&msg, 0, WM_INPUT, WM_INPUT, PM_REMOVE | PM_QS_INPUT)) while (PeekMessage(&msg, 0, WM_INPUT, WM_INPUT, PM_REMOVE | PM_QS_INPUT))
@ -257,14 +237,12 @@ void grabmouse(char a)
if (!mousegrab || !d) if (!mousegrab || !d)
{ {
GetCursorPos(&pos); GetCursorPos(&pos);
d = 1; d++;
} }
ShowCursor(a == 0); ShowCursor(a == 0);
RI_CaptureInput(a, (HWND)win_gethwnd()); RI_CaptureInput(a, (HWND)win_gethwnd());
SetCursorPos(pos.x, pos.y); SetCursorPos(pos.x, pos.y);
mousex = mousey = mouseb = 0;
} }
void readmousexy(int32_t *x, int32_t *y) void readmousexy(int32_t *x, int32_t *y)

View file

@ -71,16 +71,16 @@ static int32_t usecwd = 0;
this should be lower than the MTU size by at least the size of the UDP and ENet headers this should be lower than the MTU size by at least the size of the UDP and ENet headers
or else fragmentation will occur or else fragmentation will occur
*/ */
#define SYNCPACKETSIZE 1408 #define SYNCPACKETSIZE 1366
ENetHost * g_netServer = NULL; ENetHost * g_netServer = NULL;
ENetHost * g_netClient = NULL; ENetHost * g_netClient = NULL;
ENetPeer * g_netClientPeer = NULL; ENetPeer * g_netClientPeer = NULL;
int32_t g_netPort = 23513; int32_t g_netPort = 23513;
int32_t g_netDisconnect = 0; int32_t g_netDisconnect = 0;
// sprites of these statnums are synced to clients by the server
int8_t g_netStatnums[] = { STAT_PROJECTILE, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT, int8_t g_netStatnums[] = { STAT_PROJECTILE, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT,
STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC };
};
char g_netPassword[32]; char g_netPassword[32];
int32_t g_quitDeadline = 0; int32_t g_quitDeadline = 0;
@ -8345,7 +8345,7 @@ char CheatStrings[][MAXCHEATLEN] =
"sfm", // 26 "sfm", // 26
}; };
enum cheats enum cheatindex_t
{ {
CHEAT_CORNHOLIO, CHEAT_CORNHOLIO,
CHEAT_STUFF, CHEAT_STUFF,
@ -11836,47 +11836,42 @@ MAIN_LOOP_RESTART:
do //main loop do //main loop
{ {
static uint32_t nextrender = 0; static uint32_t nextrender = 0, next = 0;
uint32_t j; uint32_t j;
if (handleevents() && quitevent)
{
// JBF
KB_KeyDown[sc_Escape] = 1;
quitevent = 0;
}
if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode()))
{
ud.statusbarmode = 0;
G_UpdateScreenArea();
}
MUSIC_Update();
// only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO); bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO);
OSD_DispatchQueued(); // menus now call handleevents() from probe_()
while (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && ready2send && totalclock >= ototalclock+TICSPERFRAME)
{
if (handleevents() && quitevent)
{
// JBF
KB_KeyDown[sc_Escape] = 1;
quitevent = 0;
}
OSD_DispatchQueued();
G_HandleLocalKeys();
faketimerhandler();
}
if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) &&
(g_player[myconnectindex].ps->gm&MODE_GAME) && G_MoveLoop()) (g_player[myconnectindex].ps->gm&MODE_GAME) && G_MoveLoop())
continue; continue;
G_DoCheats();
if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART)) if (g_player[myconnectindex].ps->gm & (MODE_EOL|MODE_RESTART))
{ {
switch (G_EndOfLevel()) switch (G_EndOfLevel())
{ {
case 1: case 1: continue;
continue; case 2: goto MAIN_LOOP_RESTART;
case 2:
goto MAIN_LOOP_RESTART;
} }
} }
G_DoCheats();
G_HandleLocalKeys();
if (g_netClient && g_multiMapState) if (g_netClient && g_multiMapState)
{ {
for (i=g_gameVarCount-1; i>=0; i--) for (i=g_gameVarCount-1; i>=0; i--)
@ -11890,6 +11885,18 @@ MAIN_LOOP_RESTART:
g_multiMapState = NULL; g_multiMapState = NULL;
} }
if (next)
{
if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode()))
{
ud.statusbarmode = 0;
G_UpdateScreenArea();
}
next--;
nextpage();
}
j = getticks(); j = getticks();
if (r_maxfps == 0 || j >= nextrender) if (r_maxfps == 0 || j >= nextrender)
@ -11905,22 +11912,16 @@ MAIN_LOOP_RESTART:
i = 65536; i = 65536;
G_DrawRooms(screenpeek,i); G_DrawRooms(screenpeek,i);
G_DisplayRest(i);
if (getrendermode() >= 3) if (getrendermode() >= 3)
G_DrawBackground(); G_DrawBackground();
G_DisplayRest(i);
S_Update(); S_Update();
nextpage(); next++;
} }
if (g_player[myconnectindex].ps->gm&MODE_DEMO) if (g_player[myconnectindex].ps->gm&MODE_DEMO)
goto MAIN_LOOP_RESTART; goto MAIN_LOOP_RESTART;
while (!(g_player[myconnectindex].ps->gm&MODE_MENU) && ready2send && totalclock >= ototalclock+TICSPERFRAME)
faketimerhandler();
} }
while (1); while (1);
@ -12567,81 +12568,17 @@ nextdemo:
GAME_STATIC GAME_INLINE int32_t G_MoveLoop() GAME_STATIC GAME_INLINE int32_t G_MoveLoop()
{ {
/*
if (numplayers > 1)
Net_DoPrediction();
*/
Net_GetPackets(); Net_GetPackets();
while (g_player[myconnectindex].movefifoend-movefifoplc > 0) while (g_player[myconnectindex].movefifoend-movefifoplc > 0)
{
/*
TRAVERSE_CONNECT(i)
if (movefifoplc == g_player[i].movefifoend) break;
if (i != ud.multimode) break;
*/
if (G_DoMoveThings()) return 1; if (G_DoMoveThings()) return 1;
}
return 0; return 0;
} }
GAME_STATIC int32_t G_DoMoveThings(void) GAME_STATIC int32_t G_DoMoveThings(void)
{ {
int32_t i, j; int32_t i, j;
// char ch;
/*
TRAVERSE_CONNECT(i)
if (TEST_SYNC_KEY(g_player[i].sync->bits, SK_MULTIFLAG))
{
multiflag = 2;
multiwhat = (g_player[i].sync->bits>>(SK_MULTIFLAG+1))&1;
multipos = (unsigned)(g_player[i].sync->bits>>(SK_MULTIFLAG+2))&15;
multiwho = i;
if (multiwhat)
{
G_SavePlayer(multipos);
multiflag = 0;
if (multiwho != myconnectindex)
{
Bsprintf(ScriptQuotes[122],"%s^00 SAVED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]);
P_DoQuote(122,g_player[myconnectindex].ps);
}
else
{
Bstrcpy(ScriptQuotes[122],"MULTIPLAYER GAME SAVED");
P_DoQuote(122,g_player[myconnectindex].ps);
}
break;
}
else
{
// waitforeverybody();
j = G_LoadPlayer(multipos);
multiflag = 0;
if (j == 0)
{
if (multiwho != myconnectindex)
{
Bsprintf(ScriptQuotes[122],"%s^00 LOADED A MULTIPLAYER GAME",&g_player[multiwho].user_name[0]);
P_DoQuote(122,g_player[myconnectindex].ps);
}
else
{
Bstrcpy(ScriptQuotes[122],"MULTIPLAYER GAME LOADED");
P_DoQuote(122,g_player[myconnectindex].ps);
}
return 1;
}
}
}
*/
ud.camerasprite = -1; ud.camerasprite = -1;
lockclock += TICSPERFRAME; lockclock += TICSPERFRAME;
@ -12807,25 +12744,6 @@ GAME_STATIC int32_t G_DoMoveThings(void)
i = g_player[myconnectindex].ps->i; i = g_player[myconnectindex].ps->i;
/*
{
int32_t j;
packbuf[(jj = j++)] = 0;
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
Bmemcpy(&packbuf[j], &T5, sizeof(T5));
j += sizeof(T5);
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
}
*/
{ {
char buf[1024]; char buf[1024];

View file

@ -55,21 +55,28 @@ GAMEEXEC_STATIC int32_t VM_Execute(int32_t once);
void VM_ScriptInfo(void) void VM_ScriptInfo(void)
{ {
if (script) intptr_t *p;
if (!script)
return;
if (insptr)
{ {
intptr_t *p; for (p=insptr-20; p<insptr+20; p++)
if (insptr) {
for (p=insptr-20; p<insptr+20; p++) if (*p>>12&&(*p&0xFFF)<CON_END)
{ initprintf("\n%5d: %5d %s ",p-script,*p>>12,keyw[*p&0xFFF]);
if (*p>>12&&(*p&0xFFF)<CON_END) else
initprintf("\n%5d: %5d %s ",p-script,*p>>12,keyw[*p&0xFFF]); initprintf(" %d",*p);
else }
initprintf(" %d",*p);
} initprintf("\n");
if (vm.g_i)
initprintf("current actor: %d (%d)\n",vm.g_i,vm.g_sp->picnum);
initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);
} }
if (vm.g_i)
initprintf("current actor: %d (%d)\n",vm.g_i,vm.g_sp->picnum);
initprintf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);
} }
void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int32_t iPlayer, register int32_t lDist) void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int32_t iPlayer, register int32_t lDist)
@ -101,11 +108,8 @@ void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int
deletesprite(vm.g_i); deletesprite(vm.g_i);
} }
// restore old values...
Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t)); Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t));
insptr=oinsptr; insptr=oinsptr;
//AddLog("End of Execution");
} }
} }
@ -114,10 +118,7 @@ static int32_t VM_CheckSquished(void)
sectortype *sc = &sector[vm.g_sp->sectnum]; sectortype *sc = &sector[vm.g_sp->sectnum];
int32_t squishme = 0; int32_t squishme = 0;
if (vm.g_sp->picnum == APLAYER && ud.clipping) if ((vm.g_sp->picnum == APLAYER && ud.clipping) || sc->lotag == 23)
return 0;
if (sc->lotag == 23)
return 0; return 0;
squishme = (sc->floorz - sc->ceilingz < (12<<8)); // && (sc->lotag&32768) == 0; squishme = (sc->floorz - sc->ceilingz < (12<<8)); // && (sc->lotag&32768) == 0;
@ -128,7 +129,7 @@ static int32_t VM_CheckSquished(void)
if (!squishme) if (!squishme)
return 0; return 0;
P_DoQuote(10,g_player[vm.g_p].ps); P_DoQuote(10, g_player[vm.g_p].ps);
if (A_CheckEnemySprite(vm.g_sp)) vm.g_sp->xvel = 0; if (A_CheckEnemySprite(vm.g_sp)) vm.g_sp->xvel = 0;
@ -164,7 +165,7 @@ GAMEEXEC_STATIC int32_t A_Dodge(spritetype *s)
for (i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list for (i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list
{ {
if (OW == i || SECT != s->sectnum) if (OW == i/* || SECT != s->sectnum*/)
continue; continue;
bx = SX-mx; bx = SX-mx;

View file

@ -109,11 +109,11 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n)
{ {
int16_t centre; int16_t centre;
{ handleevents();
CONTROL_GetInput(&minfo);
mi += (minfo.dpitch+minfo.dz); CONTROL_GetInput(&minfo);
mii += minfo.dyaw; mi += (minfo.dpitch+minfo.dz);
} mii += minfo.dyaw;
if (x == (320>>1)) if (x == (320>>1))
centre = 320>>2; centre = 320>>2;