Esempio n. 1
0
int osdcmd_fileinfo(const osdfuncparm_t *parm)
{
	unsigned long crc, length;
	int i,j;
	char buf[256];

	if (parm->numparms != 1) return OSDCMD_SHOWHELP;
	
	if ((i = kopen4load((char *)parm->parms[0],0)) < 0) {
		OSD_Printf("fileinfo: File \"%s\" does not exist.\n", parm->parms[0]);
		return OSDCMD_OK;
	}

	length = kfilelength(i);

	crc32init(&crc);
	do {
		j = kread(i,buf,256);
		crc32block(&crc,buf,j);
	} while (j == 256);
	crc32finish(&crc);
	
	kclose(i);

	OSD_Printf("fileinfo: %s\n"
	           "  File size: %d\n"
		   "  CRC-32:    %08X\n",
		   parm->parms[0], length, crc);

	return OSDCMD_OK;
}
Esempio n. 2
0
static int osdcmd_vars(const osdfuncparm_t *parm)
{
	int showval = (parm->numparms < 1);
	
	if (!Bstrcasecmp(parm->name, "screencaptureformat")) {
		const char *fmts[2][2] = { {"TGA", "PCX"}, {"0", "1"} };
		if (showval) { OSD_Printf("captureformat is %s\n", fmts[captureformat]); }
		else {
			int i,j;
			for (j=0; j<2; j++)
				for (i=0; i<2; i++)
					if (!Bstrcasecmp(parm->parms[0], fmts[j][i])) break;
			if (j == 2) return OSDCMD_SHOWHELP;
			captureformat = i;
		}
		return OSDCMD_OK;
	}
#ifdef SUPERBUILD
	else if (!Bstrcasecmp(parm->name, "novoxmips")) {
		if (showval) { OSD_Printf("novoxmips is %d\n", novoxmips); }
		else { novoxmips = (atoi(parm->parms[0]) != 0); }
	}
	else if (!Bstrcasecmp(parm->name, "usevoxels")) {
		if (showval) { OSD_Printf("usevoxels is %d\n", usevoxels); }
		else { usevoxels = (atoi(parm->parms[0]) != 0); }
	}
#endif
	return OSDCMD_SHOWHELP;
}
Esempio n. 3
0
static int osdcmd_vars(const osdfuncparm_t *parm)
{
	int showval = (parm->numparms < 1);
	
	if (!Bstrcasecmp(parm->name, "myname")) {
		if (showval) { OSD_Printf("Your name is \"%s\"\n", myname); }
		else {
			Bstrncpy(myname, parm->parms[0], sizeof(myname)-1);
			myname[sizeof(myname)-1] = 0;
			// XXX: now send the update over the wire
		}
		return OSDCMD_OK;
	}
	else if (!Bstrcasecmp(parm->name, "showfps")) {
		if (showval) { OSD_Printf("showfps is %d\n", ud.tickrate); }
		else ud.tickrate = (atoi(parm->parms[0]) != 0);
		return OSDCMD_OK;
	}
	else if (!Bstrcasecmp(parm->name, "showcoords")) {
		if (showval) { OSD_Printf("showcoords is %d\n", ud.coords); }
		else ud.coords = (atoi(parm->parms[0]) != 0);
		return OSDCMD_OK;
	}
	else if (!Bstrcasecmp(parm->name, "useprecache")) {
		if (showval) { OSD_Printf("useprecache is %d\n", useprecache); }
		else useprecache = (atoi(parm->parms[0]) != 0);
		return OSDCMD_OK;
	}
	return OSDCMD_SHOWHELP;
}
Esempio n. 4
0
// returns number of bytes read
int32_t S_LoadSound(uint32_t num)
{

    if (num > (unsigned)g_maxSoundPos || !ud.config.SoundToggle ) return 0;

    if (EDUKE32_PREDICT_FALSE(g_sounds[num].filename == NULL))
    {
        OSD_Printf(OSD_ERROR "Sound (#%d) not defined!\n",num);
        return 0;
    }

    int32_t fp = S_OpenAudio(g_sounds[num].filename, g_loadFromGroupOnly, 0);
    if (EDUKE32_PREDICT_FALSE(fp == -1))
    {
        OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
        return 0;
    }

    int32_t l = kfilelength(fp);
    g_soundlocks[num] = 200;
    g_sounds[num].soundsiz = l;
    allocache((intptr_t *)&g_sounds[num].ptr, l, (char *)&g_soundlocks[num]);
    l = kread(fp, g_sounds[num].ptr, l);
    kclose(fp);

    return l;
}
Esempio n. 5
0
static int osdcmd_glinfo(const osdfuncparm_t *parm)
{
	char *s,*t,*u,i;
	
	if (bpp == 8) {
		OSD_Printf("glinfo: Not in OpenGL mode.\n");
		return OSDCMD_OK;
	}
	
	OSD_Printf("OpenGL Information:\n"
	           " Version:  %s\n"
		   " Vendor:   %s\n"
		   " Renderer: %s\n"
		   " Maximum anisotropy:      %.1f%s\n"
		   " BGRA textures:           %s\n"
		   " Non-x^2 textures:        %s\n"
		   " Texure compression:      %s\n"
		   " Clamp-to-edge:           %s\n"
		   " Multisampling:           %s\n"
		   " Nvidia multisample hint: %s\n"
		   " Multitexturing:          %s\n"
		   " Env combine extension:   %s\n"
		   " Extensions:\n",
		   	glinfo.version,
			glinfo.vendor,
			glinfo.renderer,
			glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)",
			glinfo.bgra ? "supported": "not supported",
			glinfo.texnpot ? "supported": "not supported",
			glinfo.texcompr ? "supported": "not supported",
			glinfo.clamptoedge ? "supported": "not supported",
			glinfo.multisample ? "supported": "not supported",
			glinfo.nvmultisamplehint ? "supported": "not supported",
			glinfo.multitex ? "supported": "not supported",
			glinfo.envcombine ? "supported": "not supported"
		);

	s = Bstrdup(glinfo.extensions);
	if (!s) OSD_Printf(glinfo.extensions);
	else {
		i = 0; t = u = s;
		while (*t) {
			if (*t == ' ') {
				if (i&1) {
					*t = 0;
					OSD_Printf("   %s\n",u);
					u = t+1;
				}
				i++;
			}
			t++;
		}
		if (i&1) OSD_Printf("   %s\n",u);
		Bfree(s);
	}
	
	return OSDCMD_OK;
}
Esempio n. 6
0
static int _internal_osdfunc_listsymbols(const osdfuncparm_t *parm)
{
	symbol_t *i;

	OSD_Printf("Symbol listing:\n");
	for (i=symbols; i!=NULL; i=i->next)
		OSD_Printf("     %s\n", i->name);
	
	return OSDCMD_OK;
}
Esempio n. 7
0
int32_t S_PlayMusic(const char *fn)
{
    if (!ud.config.MusicToggle || fn == NULL)
        return 0;

    int32_t fp = S_OpenAudio(fn, 0, 1);
    if (EDUKE32_PREDICT_FALSE(fp < 0))
    {
        OSD_Printf(OSD_ERROR "S_PlayMusic(): error: can't open \"%s\" for playback!\n",fn);
        return 0;
    }

    S_StopMusic();

    int32_t MusicLen = kfilelength(fp);

    if (EDUKE32_PREDICT_FALSE(MusicLen < 4))
    {
        OSD_Printf(OSD_ERROR "S_PlayMusic(): error: empty music file \"%s\"\n", fn);
        kclose(fp);
        return 0;
    }

    ALIGNED_FREE_AND_NULL(MusicPtr);  // in case the following allocation was never freed
    MusicPtr = (char *)Xaligned_alloc(16, MusicLen);
    g_musicSize = kread(fp, (char *)MusicPtr, MusicLen);

    if (EDUKE32_PREDICT_FALSE(g_musicSize != MusicLen))
    {
        OSD_Printf(OSD_ERROR "S_PlayMusic(): error: read %d bytes from \"%s\", expected %d\n",
                   g_musicSize, fn, MusicLen);
        kclose(fp);
        g_musicSize = 0;
        return 0;
    }

    kclose(fp);

    if (!Bmemcmp(MusicPtr, "MThd", 4))
    {
        MUSIC_PlaySong(MusicPtr, MUSIC_LoopSong);
        MusicIsWaveform = 0;
    }
    else
    {
        int32_t const mvol = MASTER_VOLUME(ud.config.MusicVolume);
        MusicVoice = FX_PlayLoopedAuto(MusicPtr, MusicLen, 0, 0,
                                       0, mvol, mvol, mvol,
                                       FX_MUSIC_PRIORITY, MUSIC_ID);
        if (MusicVoice > FX_Ok)
            MusicIsWaveform = 1;
    }

    return 0;
}
Esempio n. 8
0
static int osdcmd_setstatusbarscale(const osdfuncparm_t *parm)
{
	if (parm->numparms == 0) {
		OSD_Printf("setstatusbarscale: scale is %d%%\n", ud.statusbarscale);
		return OSDCMD_OK;
	} else if (parm->numparms != 1) return OSDCMD_SHOWHELP;

	setstatusbarscale(Batol(parm->parms[0]));
	OSD_Printf("setstatusbarscale: new scale is %d%%\n", ud.statusbarscale);
	return OSDCMD_OK;
}
Esempio n. 9
0
int osdcmd_echo(const osdfuncparm_t *parm)
{
	int i;
	for (i = 0; i < parm->numparms; i++) {
		if (i > 0) OSD_Printf(" ");
		OSD_Printf("%s", parm->parms[i]);
	}
	OSD_Printf("\n");
	
	return OSDCMD_OK;
}
Esempio n. 10
0
void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.cfg
{
    int32_t i;
    BFILE *fp;
    char *ptr = Xstrdup(setupfilename);
    char tempbuf[128];

    if (!Bstrcmp(setupfilename, SETUPFILENAME))
        Bsprintf(tempbuf, "settings.cfg");
    else Bsprintf(tempbuf, "%s_settings.cfg", strtok(ptr, "."));

    fp = Bfopen(tempbuf, "wt");

    if (fp)
    {
        Bfprintf(fp,"// this file is automatically generated by EDuke32\n");
        Bfprintf(fp,"// these settings take precedence over your main cfg file\n");
        Bfprintf(fp,"// do not modify if you lack common sense\n");

        Bfprintf(fp,"unbindall\n");

        for (i=0; i<MAXBOUNDKEYS; i++)
            if (CONTROL_KeyIsBound(i))
                Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_KeyBinds[i].key,
                CONTROL_KeyBinds[i].repeat?"":" norepeat",CONTROL_KeyBinds[i].cmdstr);

        for (i=0; i<MAXMOUSEBUTTONS; i++)
            if (CONTROL_MouseIsBound(i))
                Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_MouseBinds[i].key,
                CONTROL_MouseBinds[i].repeat?"":" norepeat",CONTROL_MouseBinds[i].cmdstr);

        OSD_WriteAliases(fp);

        if (g_crosshairSum && g_crosshairSum != DefaultCrosshairColors.r+(DefaultCrosshairColors.g<<1)+(DefaultCrosshairColors.b<<2))
            Bfprintf(fp, "crosshaircolor %d %d %d\n", CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);

        OSD_WriteCvars(fp);

        Bfclose(fp);

        if (!Bstrcmp(setupfilename, SETUPFILENAME))
            OSD_Printf("Wrote settings.cfg\n");
        else OSD_Printf("Wrote %s_settings.cfg\n",ptr);

        Bfree(ptr);
        return;
    }

    if (!Bstrcmp(setupfilename, SETUPFILENAME))
        OSD_Printf("Error writing settings.cfg: %s\n", strerror(errno));
    else OSD_Printf("Error writing %s_settings.cfg: %s\n",ptr,strerror(errno));

    Bfree(ptr);
}
Esempio n. 11
0
static int _internal_osdfunc_help(const osdfuncparm_t *parm)
{
	symbol_t *symb;

	if (parm->numparms != 1) return OSDCMD_SHOWHELP;
	symb = findexactsymbol(parm->parms[0]);
	if (!symb) {
		OSD_Printf("Help Error: \"%s\" is not a defined variable or function\n", parm->parms[0]);
	} else {
		OSD_Printf("%s\n", symb->help);
	}
	
	return OSDCMD_OK;
}
Esempio n. 12
0
int OSD_Dispatch(const char *cmd)
{
	char *workbuf, *wp, *wtp, *state;
	char *parms[MAXPARMS];
	int  numparms, restart = 0;
	osdfuncparm_t ofp;
	symbol_t *symb;
	//int i;
	
	workbuf = state = Bstrdup(cmd);
	if (!workbuf) return -1;

	do {
		numparms = 0;
		Bmemset(parms, 0, sizeof(parms));
		wp = strtoken(state, &wtp, &restart);
		if (!wp) {
			state = wtp;
			continue;
		}

		symb = findexactsymbol(wp);
		if (!symb) {
			OSD_Printf("Error: \"%s\" is not defined\n", wp);
			free(workbuf);
			return -1;
		}
		
		ofp.name = wp;
		while (wtp && !restart) {
			wp = strtoken(NULL, &wtp, &restart);
			if (wp && numparms < MAXPARMS) parms[numparms++] = wp;
		}
		ofp.numparms = numparms;
		ofp.parms    = (const char **)parms;
		ofp.raw      = cmd;
		switch (symb->func(&ofp)) {
			case OSDCMD_OK: break;
			case OSDCMD_SHOWHELP: OSD_Printf("%s\n", symb->help); break;
		}
		
		state = wtp;
	} while (wtp && restart);
	
	free(workbuf);
	
	return 0;
}
Esempio n. 13
0
void setvsync(int32_t sync)
{
    if (vsync_render == sync) return;
    vsync_render = sync;

    resetvideomode();
    if (setgamemode(fullscreen, xdim, ydim, bpp))
        OSD_Printf("restartvid: Reset failed...\n");
}
Esempio n. 14
0
static int32_t texcache_enabled(void)
{
    if (!glusetexcompr || !glusetexcache) return 0;

    if (!glinfo.texcompr || !bglCompressedTexImage2DARB || !bglGetCompressedTexImageARB)
    {
        // lacking the necessary extensions to do this
        OSD_Printf("Warning: the GL driver lacks necessary functions to use caching\n");
        glusetexcache = 0;
        return 0;
    }

    if (!texcache.index || texcache.filehandle < 0)
    {
        OSD_Printf("Warning: no active cache!\n");
        return 0;
    }

    return 1;
}
Esempio n. 15
0
int osdcmd_noclip(const osdfuncparm_t *parm)
{
	parm=parm;
	if (numplayers == 1 && ps[myconnectindex].gm & MODE_GAME) {
		osdcmd_cheatsinfo_stat.cheatnum = 20;
	} else {
		OSD_Printf("noclip: Not in a single-player game.\n");
	}
	
	return OSDCMD_OK;
}
Esempio n. 16
0
int osdcmd_usemousejoy(const osdfuncparm_t *parm)
{
	int showval = (parm->numparms < 1);
	if (!Bstrcasecmp(parm->name, "usemouse")) {
		if (showval) { OSD_Printf("usemouse is %d\n", UseMouse); }
		else {
			UseMouse = (atoi(parm->parms[0]) != 0);
			CONTROL_MouseEnabled = (UseMouse && CONTROL_MousePresent);
		}
		return OSDCMD_OK;
	}
	else if (!Bstrcasecmp(parm->name, "usejoystick")) {
		if (showval) { OSD_Printf("usejoystick is %d\n", UseJoystick); }
		else {
			UseJoystick = (atoi(parm->parms[0]) != 0);
			CONTROL_JoystickEnabled = (UseJoystick && CONTROL_JoyPresent);
		}
		return OSDCMD_OK;
	}
	return OSDCMD_SHOWHELP;
}
Esempio n. 17
0
void texcache_invalidate(void)
{
#ifdef DEBUGGINGAIDS
    OSD_Printf("texcache_invalidate()\n");
#endif
    r_downsizevar = r_downsize; // update the cvar representation when the menu changes r_downsize

    polymost_glreset();

    texcache_init();
    texcache_deletefiles();
    texcache_openfiles();
}
Esempio n. 18
0
static int _internal_osdfunc_vars(const osdfuncparm_t *parm)
{
	int showval = (parm->numparms < 1);

	if (!Bstrcasecmp(parm->name, "osdrows")) {
		if (showval) { OSD_Printf("osdrows is %d\n", osdrows); return OSDCMD_OK; }
		else {
			osdrows = atoi(parm->parms[0]);
			if (osdrows < 1) osdrows = 1;
			else if (osdrows > osdmaxrows) osdrows = osdmaxrows;
			return OSDCMD_OK;
		}
	}
	return OSDCMD_SHOWHELP;
}
Esempio n. 19
0
static int osdfunc_dumpbuildinfo(const osdfuncparm_t *parm)
{
	OSD_Printf(
		"Build engine compilation:\n"
		"  CFLAGS: %s\n"
		"  LIBS: %s\n"
		"  Host: %s\n"
		"  Compiler: %s\n"
		"  Built: %s\n",
		_engine_cflags,
		_engine_libs,
		_engine_uname,
		_engine_compiler,
		_engine_date);

	return OSDCMD_OK;
}
Esempio n. 20
0
void G_ProcessDynamicSoundMapping(const char *szLabel, int32_t lValue)
{
    int32_t i;

    if ((unsigned)lValue >= MAXSOUNDS || !szLabel)
        return;

    i = hash_find(&h_names,szLabel);
    if (i>=0)
    {
        struct dynitem *di = &g_dynSoundList[i];
#ifdef DEBUGGINGAIDS
        if (g_scriptDebug && di->staticval != lValue)
            OSD_Printf("REMAP %s (%d) --> %d\n", di->str, di->staticval, lValue);
#endif
        *di->dynvalptr = lValue;
    }
}
Esempio n. 21
0
int osdcmd_map(const osdfuncparm_t *parm)
{
	int i;
	char filename[256];

	if (parm->numparms != 1) return OSDCMD_SHOWHELP;
	
	strcpy(filename,parm->parms[0]);
	if( strchr(filename,'.') == 0)
        	strcat(filename,".map");

	if ((i = kopen4load(filename,0)) < 0) {
		OSD_Printf("map: file \"%s\" does not exist.\n", filename);
		return OSDCMD_OK;
	}
	kclose(i);

	strcpy(boardfilename, filename);
	
	if (ps[myconnectindex].gm & MODE_GAME) {
		// in-game behave like a cheat
		osdcmd_cheatsinfo_stat.cheatnum = 2;
		osdcmd_cheatsinfo_stat.volume = 0;
		osdcmd_cheatsinfo_stat.level = 7;
	} else {
		// out-of-game behave like a menu command
		osdcmd_cheatsinfo_stat.cheatnum = -1;

		ud.m_volume_number = 0;
		ud.m_level_number = 7;

                ud.m_monsters_off = ud.monsters_off = 0;

                ud.m_respawn_items = 0;
                ud.m_respawn_inventory = 0;

                ud.multimode = 1;
		
	 	newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
                if (enterlevel(MODE_GAME)) backtomenu();
	}
       
	return OSDCMD_OK;
}
Esempio n. 22
0
//
// initprintf() -- prints a string to the intitialization window
//
void initprintf(const char *f, ...)
{
	va_list va;
	char buf[1024];
	
	va_start(va, f);
	vprintf(f,va);
	va_end(va);

	va_start(va, f);
	Bvsnprintf(buf, 1024, f, va);
	va_end(va);
	OSD_Printf(buf);
#ifdef MEGAWANG
	Sys_OutputDebugString(buf);
#endif
	startwin_puts(buf);
	startwin_idle(NULL);
}
Esempio n. 23
0
static int osdfunc_setrendermode(const osdfuncparm_t *parm)
{
	int m;
	char *p;

	char *modestrs[] = {
		"classic software", "polygonal flat-shaded software",
		"polygonal textured software", "polygonal OpenGL"
	};

	if (parm->numparms != 1) return OSDCMD_SHOWHELP;
	m = Bstrtol(parm->parms[0], &p, 10);

	if (m < 0 || m > 3) return OSDCMD_SHOWHELP;

	setrendermode(m);
	OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode() ] );

	return OSDCMD_OK;
}
Esempio n. 24
0
static int32_t osdfunc_setrendermode(const osdfuncparm_t *parm)
{
    int32_t m;
    char *p;

    char *modestrs[] =
    {
        "classic software", "",
        "", "polygonal OpenGL", "great justice (Polymer)"
    };

    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
    m = Bstrtol(parm->parms[0], &p, 10);

    if (m < 0 || m > 4) return OSDCMD_SHOWHELP;

    setrendermode(m);
    OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode()]);

    return OSDCMD_OK;
}
Esempio n. 25
0
// size < 0: length of <buf> is determined using strlen()
// size >= 0: size given, for loading of LuaJIT bytecode
int L_RunString(L_State *estate, char *buf, int dofreebuf, int size, const char *name)
{
    int32_t i;
    lua_State *L = estate->L;

    // -- lua --
    Bassert(lua_gettop(L)==1);
    // on top: a traceback function
    Bassert(lua_iscfunction(L, 1));

    if (size < 0)
        i = luaL_loadstring(L, buf);
    else
        i = luaL_loadbuffer(L, buf, size, name);
    Bassert(lua_gettop(L)==2);
    if (dofreebuf)
        Bfree(buf);

    if (i == LUA_ERRMEM)
        L_OutOfMemFunc();

    if (i == LUA_ERRSYNTAX)
    {
        OSD_Printf(OSD_ERROR "state \"%s\" syntax error: %s\n", estate->name,
                   lua_tostring(L, -1));  // get err msg
        lua_pop(L, 1);  // pop errmsg
        return 3;
    }

    // call the lua chunk!
    i = lua_pcall(L, 0, 0, 1);
    Bassert(lua_gettop(L) == 1 + (i!=0));

    if (i != 0)
        L_HandleError(L, i, &L_ErrorPrint);

    Bassert(lua_gettop(L)==1);

    return i ? 4 : 0;
}
Esempio n. 26
0
int osdcmd_changelevel(const osdfuncparm_t *parm)
{
	int volume=0,level;
	char *p;

	if (!VOLUMEONE) {
		if (parm->numparms != 2) return OSDCMD_SHOWHELP;

		volume = strtol(parm->parms[0], &p, 10) - 1;
		if (p[0]) return OSDCMD_SHOWHELP;
		level = strtol(parm->parms[1], &p, 10) - 1;
		if (p[0]) return OSDCMD_SHOWHELP;
	} else {
		if (parm->numparms != 1) return OSDCMD_SHOWHELP;

		level = strtol(parm->parms[0], &p, 10) - 1;
		if (p[0]) return OSDCMD_SHOWHELP;
	}

	if (volume < 0) return OSDCMD_SHOWHELP;
	if (level < 0) return OSDCMD_SHOWHELP;

	if (!VOLUMEONE) {
		if (PLUTOPAK) {
			if (volume > 3) {
				OSD_Printf("changelevel: invalid volume number (range 1-4)\n");
				return OSDCMD_OK;
			}
		} else {
			if (volume > 2) {
				OSD_Printf("changelevel: invalid volume number (range 1-3)\n");
				return OSDCMD_OK;
			}
		}
	}

	if (volume == 0) {
		if (level > 5) {
			OSD_Printf("changelevel: invalid volume 1 level number (range 1-6)\n");
			return OSDCMD_OK;
		}
	} else {
		if (level > 10) {
			OSD_Printf("changelevel: invalid volume 2+ level number (range 1-11)\n");
			return OSDCMD_SHOWHELP;
		}
	}

	if (ps[myconnectindex].gm & MODE_GAME) {
		// in-game behave like a cheat
		osdcmd_cheatsinfo_stat.cheatnum = 2;
		osdcmd_cheatsinfo_stat.volume   = volume;
		osdcmd_cheatsinfo_stat.level    = level;
	} else {
		// out-of-game behave like a menu command
		osdcmd_cheatsinfo_stat.cheatnum = -1;
		
		ud.m_volume_number = volume;
		ud.m_level_number = level;
		
                ud.m_monsters_off = ud.monsters_off = 0;

                ud.m_respawn_items = 0;
                ud.m_respawn_inventory = 0;

                ud.multimode = 1;

                newgame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill);
                if (enterlevel(MODE_GAME)) backtomenu();
	}

	return OSDCMD_OK;
}
Esempio n. 27
0
static int osdcmd_spawn(const osdfuncparm_t *parm)
{
	long x=0,y=0,z=0;
	unsigned short cstat=0,picnum=0;
	unsigned char pal=0;
	short ang=0;
	short set=0, idx;

	if (numplayers > 1 || !(ps[myconnectindex].gm & MODE_GAME)) {
		OSD_Printf("spawn: Can't spawn sprites in multiplayer games or demos\n");
		return OSDCMD_OK;
	}
	
	switch (parm->numparms) {
		case 7:	// x,y,z
			x = Batol(parm->parms[4]);
			y = Batol(parm->parms[5]);
			z = Batol(parm->parms[6]);
			set |= 8;
		case 4:	// ang
			ang = Batol(parm->parms[3]) & 2047; set |= 4;
		case 3:	// cstat
			cstat = (unsigned short)Batol(parm->parms[2]); set |= 2;
		case 2:	// pal
			pal = (unsigned char)Batol(parm->parms[1]); set |= 1;
		case 1:	// tile number
			if (isdigit(parm->parms[0][0])) {
				picnum = (unsigned short)Batol(parm->parms[0]);
			} else {
				int i,j;
				for (j=0; j<2; j++) {
					for (i=0; i<labelcnt; i++) {
						if (
						    (j == 0 && !Bstrcmp(label+(i<<6),     parm->parms[0])) ||
						    (j == 1 && !Bstrcasecmp(label+(i<<6), parm->parms[0]))
						   ) {
							picnum = (unsigned short)labelcode[i];
							break;
						}
					}
					if (i<labelcnt) break;
				}
				if (i==labelcnt) {
					OSD_Printf("spawn: Invalid tile label given\n");
					return OSDCMD_OK;
				}
			}
			
			if (picnum >= MAXTILES) {
				OSD_Printf("spawn: Invalid tile number\n");
				return OSDCMD_OK;
			}
			break;
		default:
			return OSDCMD_SHOWHELP;
	}

	idx = spawn(ps[myconnectindex].i, (short)picnum);
	if (set & 1) sprite[idx].pal = (char)pal;
	if (set & 2) sprite[idx].cstat = (short)cstat;
	if (set & 4) sprite[idx].ang = ang;
	if (set & 8) {
		if (setsprite(idx, x,y,z) < 0) {
			OSD_Printf("spawn: Sprite can't be spawned into null space\n");
			deletesprite(idx);
		}
	}
	
	return OSDCMD_OK;
}
Esempio n. 28
0
static void L_OnOutOfMem(void)
{
    OSD_Printf("Out of memory in Lunatic.\n");
    uninitengine();
    exit(127);
}
Esempio n. 29
0
static void L_ErrorPrint(const char *errmsg)
{
    OSD_Printf(OSD_ERROR "runtime error: %s\n", errmsg);
}
Esempio n. 30
0
//
// OSD_HandleKey() -- Handles keyboard input when capturing input.
// 	Returns 0 if the key was handled internally, or the scancode if it should
// 	be passed on to the game.
//
int OSD_HandleKey(int sc, int press)
{
	char ch;
	int i,j;
	symbol_t *tabc = NULL;
	static symbol_t *lastmatch = NULL;
	
	if (!osdinited) return sc;

	if (sc == osdkey) {
		if (press) {
			OSD_ShowDisplay(osdvisible ^ 1);
			bflushchars();
		}
		return 0;//sc;
	} else if (!osdvisible) {
		return sc;
	}

	if (!press) {
		if (sc == 42 || sc == 54) // shift
			osdeditshift = 0;
		if (sc == 29 || sc == 157)	// control
			osdeditcontrol = 0;
		return 0;//sc;
	}

	keytime = gettime();

	if (sc != 15) lastmatch = NULL;		// tab

	while ( (ch = bgetchar()) ) {
		if (ch == 1) {	// control a. jump to beginning of line
		} else if (ch == 2) {	// control b, move one character left
		} else if (ch == 5) {	// control e, jump to end of line
		} else if (ch == 6) {	// control f, move one character right
		} else if (ch == 8 || ch == 127) {	// control h, backspace
			if (!osdeditcursor || !osdeditlen) return 0;
			if (!osdovertype) {
				if (osdeditcursor < osdeditlen)
					Bmemmove(osdeditbuf+osdeditcursor-1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor);
				osdeditlen--;
			}
			osdeditcursor--;
			if (osdeditcursor<osdeditwinstart) osdeditwinstart--,osdeditwinend--;
		} else if (ch == 9) {	// tab
			if (!lastmatch) {
				for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break;
				for (j=0;osdeditbuf[i] != ' ' && i < osdeditlen;j++,i++)
					osdedittmp[j] = osdeditbuf[i];
				osdedittmp[j] = 0;

				if (j > 0)
					tabc = findsymbol(osdedittmp, NULL);
			} else {
				tabc = findsymbol(osdedittmp, lastmatch->next);
				if (!tabc && lastmatch)
					tabc = findsymbol(osdedittmp, NULL);	// wrap
			}

			if (tabc) {
				for (i=osdeditcursor;i>0;i--) if (osdeditbuf[i-1] == ' ') break;
				osdeditlen = i;
				for (j=0;tabc->name[j] && osdeditlen <= EDITLENGTH;i++,j++,osdeditlen++)
					osdeditbuf[i] = tabc->name[j];
				osdeditcursor = osdeditlen;
				osdeditwinend = osdeditcursor;
				osdeditwinstart = osdeditwinend-editlinewidth;
				if (osdeditwinstart<0) {
					osdeditwinstart=0;
					osdeditwinend = editlinewidth;
				}
			
				lastmatch = tabc;
			}
		} else if (ch == 11) {	// control k, delete all to end of line
		} else if (ch == 12) {	// control l, clear screen
		} else if (ch == 13) {	// control m, enter
			if (osdeditlen>0) {
				osdeditbuf[osdeditlen] = 0;
				Bmemmove(osdhistorybuf[1], osdhistorybuf[0], (HISTORYDEPTH-1)*(EDITLENGTH+1));
				Bmemmove(osdhistorybuf[0], osdeditbuf, EDITLENGTH+1);
				if (osdhistorysize < HISTORYDEPTH) osdhistorysize++;
				if (osdexeccount == HISTORYDEPTH)
					OSD_Printf("Command Buffer Warning: Failed queueing command "
							"for execution. Buffer full.\n");
				else
					osdexeccount++;
				osdhistorypos=-1;
			}

			osdeditlen=0;
			osdeditcursor=0;
			osdeditwinstart=0;
			osdeditwinend=editlinewidth;
		} else if (ch == 16) {	// control p, previous (ie. up arrow)
		} else if (ch == 20) {	// control t, swap previous two chars
		} else if (ch == 21) {	// control u, delete all to beginning
			if (osdeditcursor>0 && osdeditlen) {
				if (osdeditcursor<osdeditlen)
					Bmemmove(osdeditbuf, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor);
				osdeditlen-=osdeditcursor;
				osdeditcursor = 0;
				osdeditwinstart = 0;
				osdeditwinend = editlinewidth;
			}
		} else if (ch == 23) {	// control w, delete one word back
			if (osdeditcursor>0 && osdeditlen>0) {
				i=osdeditcursor;
				while (i>0 && osdeditbuf[i-1]==32) i--;
				while (i>0 && osdeditbuf[i-1]!=32) i--;
				if (osdeditcursor<osdeditlen)
					Bmemmove(osdeditbuf+i, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor);
				osdeditlen -= (osdeditcursor-i);
				osdeditcursor = i;
				if (osdeditcursor < osdeditwinstart) {
					osdeditwinstart=osdeditcursor;
					osdeditwinend=osdeditwinstart+editlinewidth;
				}
			}
		} else if (ch >= 32) {	// text char
			if (!osdovertype && osdeditlen == EDITLENGTH)	// buffer full, can't insert another char
				return 0;

			if (!osdovertype) {
				if (osdeditcursor < osdeditlen) 
					Bmemmove(osdeditbuf+osdeditcursor+1, osdeditbuf+osdeditcursor, osdeditlen-osdeditcursor);
				osdeditlen++;
			} else {
				if (osdeditcursor == osdeditlen)
					osdeditlen++;
			}
			osdeditbuf[osdeditcursor] = ch;
			osdeditcursor++;
			if (osdeditcursor>osdeditwinend) osdeditwinstart++,osdeditwinend++;
		}
	}

	if (sc == 15) {		// tab
	} else if (sc == 1) {		// escape
		OSD_ShowDisplay(0);
	} else if (sc == 201) {	// page up
		if (osdhead < osdlines-1)
			osdhead++;
	} else if (sc == 209) {	// page down
		if (osdhead > 0)
			osdhead--;
	} else if (sc == 199) {	// home
		if (osdeditcontrol) {
			osdhead = osdlines-1;
		} else {
			osdeditcursor = 0;
			osdeditwinstart = osdeditcursor;
			osdeditwinend = osdeditwinstart+editlinewidth;
		}
	} else if (sc == 207) {	// end
		if (osdeditcontrol) {
			osdhead = 0;
		} else {
			osdeditcursor = osdeditlen;
			osdeditwinend = osdeditcursor;
			osdeditwinstart = osdeditwinend-editlinewidth;
			if (osdeditwinstart<0) {
				osdeditwinstart=0;
				osdeditwinend = editlinewidth;
			}
		}
	} else if (sc == 210) {	// insert
		osdovertype ^= 1;
	} else if (sc == 203) {	// left
		if (osdeditcursor>0) {
			if (osdeditcontrol) {
				while (osdeditcursor>0) {
					if (osdeditbuf[osdeditcursor-1] != 32) break;
					osdeditcursor--;
				}
				while (osdeditcursor>0) {
					if (osdeditbuf[osdeditcursor-1] == 32) break;
					osdeditcursor--;
				}
			} else osdeditcursor--;
		}
		if (osdeditcursor<osdeditwinstart)
			osdeditwinend-=(osdeditwinstart-osdeditcursor),
			osdeditwinstart-=(osdeditwinstart-osdeditcursor);
	} else if (sc == 205) {	// right
		if (osdeditcursor<osdeditlen) {
			if (osdeditcontrol) {
				while (osdeditcursor<osdeditlen) {
					if (osdeditbuf[osdeditcursor] == 32) break;
					osdeditcursor++;
				}
				while (osdeditcursor<osdeditlen) {
					if (osdeditbuf[osdeditcursor] != 32) break;
					osdeditcursor++;
				}
			} else osdeditcursor++;
		}
		if (osdeditcursor>=osdeditwinend)
			osdeditwinstart+=(osdeditcursor-osdeditwinend),
			osdeditwinend+=(osdeditcursor-osdeditwinend);
	} else if (sc == 200) {	// up
		if (osdhistorypos < osdhistorysize-1) {
			osdhistorypos++;
			memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1);
			osdeditlen = osdeditcursor = 0;
			while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++;
			if (osdeditcursor<osdeditwinstart) {
				osdeditwinend = osdeditcursor;
				osdeditwinstart = osdeditwinend-editlinewidth;
				
				if (osdeditwinstart<0)
					osdeditwinend-=osdeditwinstart,
					osdeditwinstart=0;
			} else if (osdeditcursor>=osdeditwinend)
				osdeditwinstart+=(osdeditcursor-osdeditwinend),
				osdeditwinend+=(osdeditcursor-osdeditwinend);
		}
	} else if (sc == 208) {	// down
		if (osdhistorypos >= 0) {
			if (osdhistorypos == 0) {
				osdeditlen=0;
				osdeditcursor=0;
				osdeditwinstart=0;
				osdeditwinend=editlinewidth;
				osdhistorypos = -1;
			} else {
				osdhistorypos--;
				memcpy(osdeditbuf, osdhistorybuf[osdhistorypos], EDITLENGTH+1);
				osdeditlen = osdeditcursor = 0;
				while (osdeditbuf[osdeditcursor]) osdeditlen++, osdeditcursor++;
				if (osdeditcursor<osdeditwinstart) {
					osdeditwinend = osdeditcursor;
					osdeditwinstart = osdeditwinend-editlinewidth;
					
					if (osdeditwinstart<0)
						osdeditwinend-=osdeditwinstart,
						osdeditwinstart=0;
				} else if (osdeditcursor>=osdeditwinend)
					osdeditwinstart+=(osdeditcursor-osdeditwinend),
					osdeditwinend+=(osdeditcursor-osdeditwinend);
			}
		}
	} else if (sc == 42 || sc == 54) {	// shift
		osdeditshift = 1;
	} else if (sc == 29 || sc == 157) {	// control
		osdeditcontrol = 1;
	} else if (sc == 58) {	// capslock
		osdeditcaps ^= 1;
	} else if (sc == 28 || sc == 156) {	// enter
	} else if (sc == 14) {		// backspace
	} else if (sc == 211) {	// delete
		if (osdeditcursor == osdeditlen || !osdeditlen) return 0;
		if (osdeditcursor <= osdeditlen-1) Bmemmove(osdeditbuf+osdeditcursor, osdeditbuf+osdeditcursor+1, osdeditlen-osdeditcursor-1);
		osdeditlen--;
	}
	
	return 0;
}