Go Back   Champions of Regnum > English > Technical Support > Linux

Linux Technical issues under Linux platform

Reply
 
Thread Tools Display Modes
Old 09-09-2009, 04:56 PM   #21
Zas_
Count
 
Zas_'s Avatar
 
Join Date: Jun 2009
Location: France
Posts: 1,024
Zas_ is on a distinguished road
Default

Quote:
Originally Posted by onemyndseye View Post
Looking at Zas patch while it is certainly nice work is abit too much for a repo candidate...
My last patch is working well and is not that different from initial patch.
0-9 hack is specific to azerty keyboards (but really useful).
Others hacks should'nt conflict with anything.

But imho, such a hack should not be included in debian packages (imho, the thread title is wrong, this is not a true "fix").

A definitive fix should be provided by NGD for all those issues, ASAP.
__________________
Annavilya / War-Luck (Haven)
Zas_ no ha iniciado sesión   Reply With Quote
Old 09-10-2009, 04:33 AM   #22
onemyndseye
Master
 
onemyndseye's Avatar
 
Join Date: Jul 2008
Location: South Central USA
Posts: 260
onemyndseye is on a distinguished road
Default

certainy true...

However I was not clear... Im putting together a package of extra utils one of which being a script to manage the local RO data archive. .. and I am gathering other such usfull scripts/hacks/fixes to go into this package as it seems the correct place... In the main package itself? Yes I completely agree.


I did a comile after applying your patch. Works very nicely! The ones that concern me the most for using in this "extras" package is is things like swaping X/K since they apply to the login screen.. this will confuse some people hahaa.

However I am having seconds thoughts about including this as the part of it that is most usfull to the most number of players is the mouse fix and "should be fixed soon". And is all easy enough to apply.. what I may do instead is include a script to in Wizard form to build it and copy the needed lib to your RO directory.
__________________
RA/Syrtis Hunter LVL50: Elusis
RA/Syrtis Barba LVL50: Artemisia
RA/Syrtis Conju Lvl45: Nellas Miriel

Last edited by onemyndseye; 09-10-2009 at 07:46 AM.
onemyndseye no ha iniciado sesión   Reply With Quote
Old 09-14-2009, 01:48 PM   #23
Arafails
Baron
 
Arafails's Avatar
 
Join Date: Nov 2007
Location: Not where it looks like, to either of us.
Posts: 706
Arafails will become famous soon enough
Default

Could check the contents of $_ to make sure you're running the game and not the launcher.
__________________
If you can't detect sarcasm yourself, please pay attention when it's pointed out to you.
Arathael :: Wyrd Sceote :: Gwn M'gerSoul Taker, Imperial Guard of Ignis
Arafails no ha iniciado sesión   Reply With Quote
Old 09-28-2009, 09:11 AM   #24
Angelwinged_Devil
Banned
 
Angelwinged_Devil's Avatar
 
Join Date: Feb 2007
Location: Under your skin Posts: 1337
Posts: 2,490
Angelwinged_Devil is on a distinguished road
Default

could you update main post with all the udates/upgrades?
Angelwinged_Devil no ha iniciado sesión   Reply With Quote
Old 11-17-2009, 11:58 PM   #25
Zas_
Count
 
Zas_'s Avatar
 
Join Date: Jun 2009
Location: France
Posts: 1,024
Zas_ is on a distinguished road
Default

Here is a new version of the hack, it adds the possibility to map
mouse buttons 8 and 9 (tested on Logitech G5) to keyboard keys.

By default, i mapped:
- spacebar to keypad 0 (same effect)
- button UP on mouse to keypad 8 (cast spell 8)
- button DOWN on mouse to keypad 9 (cast spell 9)

It fixes the mouse click vs enter issue.

Post with previous version was edited, the new patch is there
__________________
Annavilya / War-Luck (Haven)

Last edited by Zas_; 11-23-2009 at 08:19 PM. Reason: 0.6 is out
Zas_ no ha iniciado sesión   Reply With Quote
Old 12-06-2009, 07:39 AM   #26
Plover
Apprentice
 
Join Date: Nov 2007
Posts: 84
Plover is on a distinguished road
Default

If somebody's making a package with useful addons in the form of a preloaded library, I'd suggest adding a feature to limit fps... I wrote a small library which does this, via LD_PRELOAD, since RO would do painful things to my small laptop while playing (painful as in heat/ridiculous cpu usage).

I'd package this up nicely for others, but I"m no good at that, so I"ll just post the relevant code and a video of it working, and hopefully if someone else finds this useful they could consider adding it.

EDIT: This doesn't work with the new gfx engine. I think the problem is probably with my messing with OpenGL states

http://markhamlin.net//tempfiles/fpscontrol.ogv

Code:
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glut.h>

#include <stdio.h>
#include <time.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <unistd.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>

typedef struct {
	clock_t framerateClockLastTime;
	unsigned int framerateClockTimeCount;
	unsigned int targetFPS;
	int frameSleepTime;
	
	Display *display;
	
	double lastIncreaseFramerateTime;
	double lastDecreaseFramerateTime;
} PloverGraphics;

PloverGraphics *ploverGraphics_g;

void ploverGraphicsInit(void);
Code:
void print_string(GLuint base, char* s);
void init_font(Display *dpy,GLuint base, char* f);
void font_init(Display *dpy,char* f);

static void (*realglXSwapBuffers) (void *display,int type);
static int (*realXNextEvent) (Display *display,XEvent *event_return);

static GLuint font_base;

void ploverGraphicsInit(void) {
	char path[1024];
	
	sprintf(path,"%s/live/libs/libopengl_api.so",getenv("SCRIPT_DIR"));
	
	void *lib;
	lib = dlopen(path,RTLD_LAZY);
	if (lib){
		realglXSwapBuffers = dlsym(lib,"glXSwapBuffers");
		dlclose(lib);
	}
	else {
		realglXSwapBuffers = NULL;
	}
	
	lib = dlopen("/usr/lib/libX11.so",RTLD_LAZY);
	if (lib){
		printf("Lib opened\n");
		realXNextEvent = dlsym(lib,"XNextEvent");
		dlclose(lib);
	}
	else {
		printf("/usr/lib/libX11.so failed to open!\n");
		realXNextEvent = NULL;
	}
	
	ploverGraphics_g->display = NULL;
	
	ploverGraphics_g->framerateClockLastTime = clock();
	ploverGraphics_g->framerateClockTimeCount = 0;
	ploverGraphics_g->frameSleepTime = 1;
	
	ploverGraphics_g->targetFPS = 45;
	
	ploverGraphics_g->lastIncreaseFramerateTime = 0;
	ploverGraphics_g->lastDecreaseFramerateTime = 0;
}

void glXSwapBuffers( Display *dpy, GLXDrawable drawable ) {
	int i;
	
	if (!ploverGraphics_g->display){
		// 
		// Handle some one-time initialization where you need display
		// 
		ploverGraphics_g->display = dpy;
		
		font_init(dpy,"-adobe-courier-bold-r-normal--24*");
	}
	
	if (!realglXSwapBuffers){
		printf("libplover warning: This should not be called!\n");
		return;
	}
	
	// 
	// Setup custom drawing
	// 
	
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	
	glDisable(GL_LIGHTING);
	glDisable(GL_TEXTURE_2D);
	glShadeModel( GL_SMOOTH );
	glEnable (GL_LINE_SMOOTH);
	glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glLoadIdentity();
	glOrtho(0,1,0,1,0,1);
	glTranslatef(0.0,0.0,0.0);
	
	// 
	// Do custom drawing
	// 
	
	double currentTime = getTime();
	
	char swapString[256];
	
	const GLfloat upArrow[] = {
		-1.0,0.0,
		1.0,0.0,
		0.0,1.0,
	};
	
	char showFPS = 0;
	
	// 
	// Show the up arrow...
	// 
	
	if (currentTime-ploverGraphics_g->lastIncreaseFramerateTime < 1.0){
		showFPS = 1;
		
		glPushMatrix();
		
		glTranslatef(0.5,0.8,0.0);
		glScalef(0.04,0.08,1.0);
		
		glColor4f(0.0,1.0,0.3,1.0-(currentTime-ploverGraphics_g->lastIncreaseFramerateTime));
	    	glBegin(GL_TRIANGLES);
	    	for (i = 0; i < 3; i++)
	    		glVertex2f(upArrow[i*2],upArrow[i*2+1]);
	    	glEnd();
		
		glPopMatrix();
	}
	
	// 
	// Show the down arrow...
	// 
	if (currentTime-ploverGraphics_g->lastDecreaseFramerateTime < 1.0){
		showFPS = 1;
		
		glPushMatrix();
		
		glTranslatef(0.5,0.8,0.0);
		glScalef(0.04,0.08,1.0);
		
		glColor4f(1.0,0.0,0.3,1.0-(currentTime-ploverGraphics_g->lastDecreaseFramerateTime));
	    	glBegin(GL_TRIANGLES);
	    	for (i = 0; i < 3; i++)
	    		glVertex2f(upArrow[i*2],-upArrow[i*2+1]);
	    	glEnd();
		
		glPopMatrix();
	}
	
	
	// 
	// Draw the target fps if it is needed
	// 
	if (showFPS){
		glPushMatrix();
		glTranslatef(0.5,0.8,0.0);
		
		glColor4f(0.0,0.0,1.0,1.0);
		glRasterPos2f(0.05,0.0);
		sprintf(swapString,"%d Target FPS",ploverGraphics_g->targetFPS);
		print_string(font_base,swapString);
		glPopMatrix();
	}
	
	// 
	// Done custom drawing
	// 
	
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	
	// 
	// Swap buffers; Done drawing this frame
	// 
	realglXSwapBuffers(dpy,drawable);
	
	// 
	// Put a 45FPS cap on framerate!
	// 
	ploverGraphics_g->framerateClockTimeCount++;
	if (ploverGraphics_g->framerateClockTimeCount > 10){
		ploverGraphics_g->framerateClockTimeCount = 0;
		clock_t now = clock();
		double timePerFrame = (((double)(now-ploverGraphics_g->framerateClockLastTime))/(double)CLOCKS_PER_SEC)/(double)10.0;
		ploverGraphics_g->frameSleepTime = (double)1000000.0*((double)(1.0/(double)ploverGraphics_g->targetFPS)-timePerFrame);
		ploverGraphics_g->framerateClockLastTime = now;
	}
	if (ploverGraphics_g->frameSleepTime > 0)
		usleep((unsigned int)ploverGraphics_g->frameSleepTime);
}

int XNextEvent(Display *display,XEvent *event_return) {
	KeySym key;
	char text[255];
	
	int returnVal = realXNextEvent(display,event_return);
	
	if (event_return->type == KeyPress && XLookupString(&event_return->xkey,text,255,&key,0)==1) {
		if (text[0] == ']'){
			ploverGraphics_g->targetFPS += 5;
			ploverGraphics_g->lastIncreaseFramerateTime = getTime();
		}
		if (text[0] == '[' && ploverGraphics_g->targetFPS > 5){
			ploverGraphics_g->targetFPS -= 5;
			ploverGraphics_g->lastDecreaseFramerateTime = getTime();
		}
		
		//printf("You pressed the %c key!\n",text[0]);
	}
	if (event_return->type == ButtonPress) {
		//printf("You pressed a button at (%i,%i)\n",event_return->xbutton.x,event_return->xbutton.y);
	}
	
	return returnVal;
}

void print_string(GLuint base, char* s)
{
   if (!glIsList(font_base)) {
      fprintf(stderr, "print_string(): Bad display list. - Exiting.\n");
      exit (-1);
   }
   else if (s && strlen(s)) {
      glPushAttrib(GL_LIST_BIT);
      glListBase(base);
      glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *)s);
      glPopAttrib();
   }
}

void init_font(Display *dpy,GLuint base, char* f)
{
	XFontStruct* font_info;
	int first;
	int last;
	
	/* Load the font. */
	font_info = XLoadQueryFont(dpy, f);
	if (!font_info) {
		fprintf(stderr, "XLoadQueryFont() failed - Exiting.\n");
		exit(-1);
	}
	else {
		/* Tell GLX which font & glyphs to use. */
		first = font_info->min_char_or_byte2;
		last  = font_info->max_char_or_byte2;
		glXUseXFont(font_info->fid, first, last-first+1, base+first);
	}
}

void font_init(Display *dpy,char* f)
{
   font_base = glGenLists(256);
   if (!glIsList(font_base)) {
      fprintf(stderr, "my_init(): Out of display lists. - Exiting.\n");
      exit (-1);
   }
   else {
      init_font(dpy,font_base, f);
   }
}
__________________
Syrtis
Ra: Plover : 50 Hunter || Plovercita : 38 Barb
Horus:Plover : 50 Marx || Hollyfeld : 50 Conj || Plovador: 50 Hunter

Last edited by Plover; 12-06-2009 at 07:45 AM. Reason: Remembered it doesn't work on new client
Plover no ha iniciado sesión   Reply With Quote
Old 12-13-2009, 06:36 AM   #27
Plover
Apprentice
 
Join Date: Nov 2007
Posts: 84
Plover is on a distinguished road
Default

I finally got the experimental client installed, and got my FPS fix working like a charm there. The change was that the OpenGL api is now located at /usr/lib/libGL.so, instead of in the ~r/regnum/live/libs/ directory. To use the above code snippet with the new client, replace the init function with the one below.

Hope this works for people!

Code:
void ploverGraphicsInit(void) {
	
	void *lib;
	
	lib = dlopen("/usr/lib/libGL.so",RTLD_LAZY);
	if (lib){
		realglXSwapBuffers = dlsym(lib,"glXSwapBuffers");
		dlclose(lib);
	}
	else {
		realglXSwapBuffers = NULL;
	}
	
	lib = dlopen("/usr/lib/libX11.so",RTLD_LAZY);
	if (lib){
		printf("Lib opened\n");
		realXNextEvent = dlsym(lib,"XNextEvent");
		dlclose(lib);
	}
	else {
		printf("/usr/lib/libX11.so failed to open!\n");
		realXNextEvent = NULL;
	}
	
	ploverGraphics_g->display = NULL;
	
	ploverGraphics_g->framerateClockLastTime = clock();
	ploverGraphics_g->framerateClockTimeCount = 0;
	ploverGraphics_g->frameSleepTime = 1;
	
	ploverGraphics_g->targetFPS = 45;
	
	ploverGraphics_g->lastIncreaseFramerateTime = 0;
	ploverGraphics_g->lastDecreaseFramerateTime = 0;
}
__________________
Syrtis
Ra: Plover : 50 Hunter || Plovercita : 38 Barb
Horus:Plover : 50 Marx || Hollyfeld : 50 Conj || Plovador: 50 Hunter
Plover no ha iniciado sesión   Reply With Quote
Old 12-13-2009, 08:29 AM   #28
Zas_
Count
 
Zas_'s Avatar
 
Join Date: Jun 2009
Location: France
Posts: 1,024
Zas_ is on a distinguished road
Default

Hi Plover,

could you please give a minimal compilation and usage guide ?

Thanks
__________________
Annavilya / War-Luck (Haven)
Zas_ no ha iniciado sesión   Reply With Quote
Old 12-14-2009, 05:09 PM   #29
Plover
Apprentice
 
Join Date: Nov 2007
Posts: 84
Plover is on a distinguished road
Default

Contained is a readme, and a launcher script. The version in this zip is for the original, client, so replace that function I previously posted to get it working on the new one.

I do realize the drawing code (and how I'm getting time, etc) ought to be made more efficient, but it's good enough for now.

http://markhamlin.net/tempfiles/libploverfps_1.zip

Usage: Launch RO using the "plauncher" (cleverly stands for ploverlauncher - i know, who would've guessed). Press ] to increase max-fps, and [ to decrease max-fps. You should see a graphic indicating what the current max(target) fps is.
__________________
Syrtis
Ra: Plover : 50 Hunter || Plovercita : 38 Barb
Horus:Plover : 50 Marx || Hollyfeld : 50 Conj || Plovador: 50 Hunter

Last edited by Plover; 12-14-2009 at 05:11 PM. Reason: Added usage
Plover no ha iniciado sesión   Reply With Quote
Old 01-22-2010, 08:44 AM   #30
linearguild
Initiate
 
linearguild's Avatar
 
Join Date: Dec 2008
Location: Spawned at save
Posts: 198
linearguild is on a distinguished road
Default

Can we have this thread stickied, please?
__________________
Xia - Marksman · Saiph - Warlock · Amaron - Conjurer
A proud member of
I N Q U I S I T I O N
linearguild no ha iniciado sesión   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:36 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
NGD Studios 2002-2024 © All rights reserved