GCC-built plugins no longer insta-crash. Go Mozilla! You rule!...

'make npqtv-dbg' works for me.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3152 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-04-03 07:31:54 +00:00
parent 616200895b
commit 6ebabd8d88
3 changed files with 84 additions and 21 deletions

View file

@ -229,6 +229,7 @@ endif
GLCFLAGS=-DGLQUAKE
SWCFLAGS=-DSWQUAKE
D3DCFLAGS=-DD3DQUAKE
NPQTVCFLAGS=-DNPQTV
CLIENT_OBJS = $(CLIENT_ASM_OBJS) \
textedit.o \
@ -506,6 +507,7 @@ ifeq ($(FTE_TARGET),win32)
SV_DIR=sv_mingw
SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) resources.o
ifeq ($(USEASM),true)
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o resources.o
else
@ -518,6 +520,18 @@ endif
GLB_DIR=gl_mgw
GLCL_DIR=glcl_mgw
ifeq ($(USEASM),true)
NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o npplug.o sys_npqtv.o ../../ftequake/npapi.def
else
NPQTVCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidnt.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o npplug.o sys_npqtv.o ../../ftequake/npapi.def
endif
NPQTV_DLL_NAME=../npqtv.dll
NPQTVCL_DLL_NAME=../npqtvcl.dll
NPQTV_LDFLAGS=--enable-stdcall-fixup $(GLLDFLAGS) $(IMAGELDFLAGS) -ldxguid -lwsock32 -lwinmm -lgdi32 -lole32 -shared
NPQTV_CFLAGS=$(NPQTVCFLAGS) $(GLCFLAGS) $(W32_CFLAGS)
NPQTVB_DIR=npqtv_mgw
NPQTVCL_DIR=npqtvcl_mgw
ifeq ($(USEASM),true)
SWCL_OBJS=$(SOFTWARE_OBJS) vid_ddraw.o vid_dib.o vid_win2.o snd_win.o snd_directx.o cd_win.o in_win.o sys_win.o sys_dosa.o resources.o
else
@ -795,6 +809,11 @@ VPATH = $(BASE_DIR) : $(CLIENT_DIR) : $(GL_DIR) : $(COMMON_DIR) : $(SW_DIR) : $(
$(OUT_DIR)/resources.o : winquake.rc
$(WINDRES) -I$(CLIENT_DIR) -O coff $< $@
#npAPI stuff requires some extra resources
$(OUT_DIR)/npplug.o : ftequake/npplug.rc
$(WINDRES) -I$(CLIENT_DIR) -O coff $< $@
#$(OUT_DIR)/%.d: %.c
# @set -e; rm -f $@; \
# $(CC) -MM $(ALL_CFLAGS) $< > $@.$$$$; \
@ -884,6 +903,21 @@ d3d-dbg:
$(MAKE) d3d-tmp TYPE=_clsv-dbg OUT_DIR="$(DEBUG_DIR)/$(D3DB_DIR)"
npqtvcl-tmp:
$(MAKE) $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(NPQTVCL_DLL_NAME)" WCFLAGS="$(NPQTV_CFLAGS)" LDFLAGS="$(NPQTV_LDFLAGS) $(LDFLAGS)" SOBJS="$(NPQTVCL_OBJS)"
npqtv-tmp:
$(MAKE) $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(NPQTV_DLL_NAME)" WCFLAGS="$(NPQTV_CFLAGS)" LDFLAGS="$(NPQTV_LDFLAGS) $(LDFLAGS)" SOBJS="$(NPQTVCL_OBJS)"
npqtvcl-rel:
$(MAKE) npqtvcl-tmp TYPE=_cl-rel OUT_DIR="$(RELEASE_DIR)/$(NPQTVCL_DIR)"
npqtvcl-dbg:
$(MAKE) npqtvcl-tmp TYPE=_cl-dbg OUT_DIR="$(DEBUG_DIR)/$(NPQTVCL_DIR)"
npqtv-rel:
$(MAKE) npqtv-tmp TYPE=_cl-rel OUT_DIR="$(RELEASE_DIR)/$(NPQTVB_DIR)"
npqtv-dbg:
$(MAKE) npqtv-tmp TYPE=_clsv-dbg OUT_DIR="$(DEBUG_DIR)/$(NPQTVB_DIR)"
glcl-tmp:
$(MAKE) $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(GLCL_EXE_NAME)" WCFLAGS="$(GL_CFLAGS)" LDFLAGS="$(GL_LDFLAGS) $(LDFLAGS)" SOBJS="$(GLCL_OBJS)"
gl-tmp:
@ -970,6 +1004,7 @@ help:
@-echo "sw"
@-echo "m"
@-echo "mingl"
@-echo "npqtv (FTE_TARGET=win32 only, for now)"
@-echo "d3d (for windows builds)"
@-echo "mcl (currently broken)"
@-echo "glcl (currently broken)"

View file

@ -773,6 +773,10 @@ int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, i
#include <jerror.h>
#endif
#ifndef JPEG_FALSE
#define JPEG_BOOL boolean
#endif
@ -821,7 +825,7 @@ typedef struct {
int currentpos;
int maxlen;
JOCTET * buffer; /* start of buffer */
boolean start_of_file; /* have we gotten any data yet? */
JPEG_BOOL start_of_file; /* have we gotten any data yet? */
} my_source_mgr;
typedef my_source_mgr * my_src_ptr;
@ -837,7 +841,7 @@ init_source (j_decompress_ptr cinfo)
src->start_of_file = TRUE;
}
METHODDEF(boolean)
METHODDEF(JPEG_BOOL)
fill_input_buffer (j_decompress_ptr cinfo)
{
my_source_mgr *src = (my_source_mgr*) cinfo->src;
@ -1037,7 +1041,7 @@ METHODDEF(void) init_destination (j_compress_ptr cinfo)
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
}
METHODDEF(boolean) empty_output_buffer (j_compress_ptr cinfo)
METHODDEF(JPEG_BOOL) empty_output_buffer (j_compress_ptr cinfo)
{
my_destination_mgr *dest = (my_destination_mgr*) cinfo->dest;

View file

@ -2,6 +2,12 @@
#include "winquake.h"
#define bool int //we ain't c++ (grr microsoft stdbool.h gief!)
#ifdef _WIN32
#ifndef _WINDOWS
#define _WINDOWS //stupid GCC
#endif
#endif
#include "npapi/npupp.h"
#define NPQTV_VERSION 0.1
@ -19,10 +25,11 @@ NPNetscapeFuncs *browserfuncs;
#ifdef _WIN32
#ifndef GetWindowLongPtr
#define GetWindowLongPtr (void*)GetWindowLong
#define GetWindowLongPtr GetWindowLong
#endif
#ifndef SetWindowLongPtr
#define SetWindowLongPtr(w,p,v) SetWindowLong(w,p,(LONG)(v))
#define SetWindowLongPtr SetWindowLong
#define LONG_PTR LONG
#endif
@ -64,12 +71,12 @@ void VFSPIPE_Close(vfsfile_t *f)
free(p->data);
free(p);
}
int VFSPIPE_GetLen(vfsfile_t *f)
unsigned long VFSPIPE_GetLen(vfsfile_t *f)
{
vfspipe_t *p = (vfspipe_t*)f;
return p->writepos - p->readpos;
}
int VFSPIPE_Tell(vfsfile_t *f)
unsigned long VFSPIPE_Tell(vfsfile_t *f)
{
return 0;
}
@ -411,7 +418,7 @@ LRESULT CALLBACK MyPluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
{
struct qstream *str;
struct context *ctx;
ctx = GetWindowLongPtr(hWnd, GWL_USERDATA);
ctx = (struct context *)GetWindowLongPtr(hWnd, GWL_USERDATA);
if (!ctx)
return DefWindowProc(hWnd, msg, wParam, lParam);
@ -448,6 +455,8 @@ LRESULT CALLBACK MyPluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
{
switch(ctx->qtvf.connectiontype)
{
default:
break;
case QTVCT_STREAM:
Cmd_ExecuteString(va("qtvplay %s", ctx->qtvf.server), RESTRICT_LOCAL);
break;
@ -577,7 +586,10 @@ LRESULT CALLBACK MyPluginWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
DrawWndBack(ctx, hWnd, hdc, &paint);
SetBkMode(hdc, TRANSPARENT);
if (!activecontext)
TextOutA(hdc, 0, 0, "Click to activate", 19);
{
s = "Click to activate";
TextOutA(hdc, 0, 0, s, strlen(s));
}
if (ctx->availver)
{
s = va("Your plugin is out of date");
@ -615,14 +627,21 @@ NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
{
int i;
struct context *ctx;
if (!instance)
if (!instance || instance->pdata)
{
return NPERR_INVALID_INSTANCE_ERROR;
}
if (mode != NP_EMBED && mode != NP_FULL)
{
return NPERR_INVALID_PLUGIN_ERROR;
}
ctx = malloc(sizeof(struct context));
if (!ctx)
{
return NPERR_OUT_OF_MEMORY_ERROR;
}
memset(ctx, 0, sizeof(struct context));
@ -683,12 +702,15 @@ NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save)
struct context *ctx = instance->pdata;
struct context *prev;
if (!ctx)
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef _WIN32
if (ctx->window.window)
{
if (ctx->oldproc)
SetWindowLongPtr(ctx->window.window, GWL_WNDPROC, ctx->oldproc);
SetWindowLongPtr(ctx->window.window, GWL_USERDATA, NULL);
SetWindowLongPtr(ctx->window.window, GWL_WNDPROC, (LONG_PTR)ctx->oldproc);
SetWindowLongPtr(ctx->window.window, GWL_USERDATA, (LONG_PTR)NULL);
}
#endif
@ -729,9 +751,14 @@ NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window)
struct context *ctx = instance->pdata;
#ifdef _WIN32
HWND oldwindow = ctx->window.window;
HWND oldwindow;
WNDPROC p;
if (!ctx)
return NPERR_INVALID_INSTANCE_ERROR;
oldwindow = ctx->window.window;
memcpy(&ctx->window, window, sizeof(ctx->window));
//if the window changed
@ -740,16 +767,16 @@ NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window)
//we switched window?
if (oldwindow && ctx->oldproc)
{
SetWindowLongPtr(oldwindow, GWL_WNDPROC, ctx->oldproc);
SetWindowLongPtr(oldwindow, GWL_WNDPROC, (LONG_PTR)ctx->oldproc);
ctx->oldproc = NULL;
}
p = GetWindowLongPtr(ctx->window.window, GWL_WNDPROC);
p = (WNDPROC)GetWindowLongPtr(ctx->window.window, GWL_WNDPROC);
if (p != MyPluginWndProc)
ctx->oldproc = p;
SetWindowLongPtr(ctx->window.window, GWL_WNDPROC, MyPluginWndProc);
SetWindowLongPtr(ctx->window.window, GWL_USERDATA, ctx);
SetWindowLongPtr(ctx->window.window, GWL_WNDPROC, (LONG_PTR)MyPluginWndProc);
SetWindowLongPtr(ctx->window.window, GWL_USERDATA, (LONG_PTR)ctx);
if (ctx->contextrunning && mainwindow && oldwindow == sys_hijackwindow)
{
@ -772,7 +799,7 @@ NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
NPStream* stream, NPBool seekable,
uint16* stype)
{
struct context *ctx = instance->pdata;
// struct context *ctx = instance->pdata;
struct qstream *qstr;
stream->pdata = qstr = malloc(sizeof(*qstr) + strlen(stream->url));
@ -932,9 +959,6 @@ NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value)
return NPERR_NO_ERROR;
}
NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs)
{
browserfuncs = pFuncs;