Jump to content
Eternal Lands Official Forums

Cirion

Members
  • Content count

    13
  • Joined

  • Last visited

About Cirion

  • Rank
    Rabbit
  1. C Question, Map Editor

    This is undefined behaviour and a bad thing. Undefined behaviour means the compiler is free to make anything it wants including setting fire to your house , so this should be avoided.
  2. Error: Can't open file key.ini

    ok I was probably unclear, I meant that the other use of configdir in elconfig.c adds a slash to the path built (grep for configdir) and I meant to fix the inconsistency by having both places behave similarly.
  3. in-game notepad

    How would this work for expansion on text buffer: I did it for put_char_in_buffer() only but should be added to the other put_xxxx_in_buffer functions if its usable. int grow_text_message(text_message *buf) { Uint8 *old_data = buf->data; if (buf->size + MAX_TEXT_MESSAGE_LENGTH >= MAX_DISPLAY_TEXT_BUFFER_LENGTH) { // dont grow over max limit return 0; } buf->size += MAX_TEXT_MESSAGE_LENGTH; buf->data = (Uint8*)calloc(buf->size, sizeof(Uint8)); if (buf->len) my_strncp(buf->data, old_data, buf->len); buf->data[buf->len] = '\0'; // just for safety free(old_data); // we were able to grow buffer so tell caller so return 1; } using this changes put_char_in_buffer() to this: int put_char_in_buffer (text_message *buf, Uint8 ch, int pos) { int i, nlen; // if (pos < 0 || pos > buf->len) return 0; if (pos < 0) return 0; if (pos >= buf->size) { // we need make buffer bigger if (grow_text_message(buf) == 0) return 0; } // First shift everything after pos to the right nlen = buf->len + 1; if (nlen >= buf->size) nlen = buf->size - 1; buf->data[nlen] = '\0'; for (i = nlen - 1; i > pos; i--) buf->data[i] = buf->data[i-1]; // insert the new character, and update the length buf->data[pos] = ch; buf->len = nlen; return 1; }
  4. in-game notepad

    Fix: notepad.h, new prototype void display_popup_win (int parent_win, char* label, int maxlen); notepad.c, function params + call to create_window: void display_popup_win (int parent_win, char* label, int maxlen) popup_win = create_window (win_prompt, parent_win, 0, popup_x, popup_y, popup_x_len, popup_y_len, ELW_WIN_DEFAULT); notepad.c, replace function int notepadAddCategory(widget_list *widget, int mx, int my, Uint32 flags) { display_popup_win (notepad_win, label_note_name, 16); return 1; }
  5. bugfix keys.c:69 strcat(key_ini, "/key.ini"); It would be useful to get a time stamp in the logfiles
  6. in-game notepad

    ok that makes sense, but it also should be possible to set the parent of any popup window, normally they belong to some other window. Maybe add a parent window parameter? Today when it is not a child window you can do this: - open notepad - click add category - close the notepad and you have the popup window up but no notepad EDIT: btw you know that int notepadAddCategory() is called like this: widget->OnClick (widget_list *widget, int mx, int my, Uint32 flags)? If we fix the notepadAddCategory params, cant a parent be extracted from first param and used in display_popup_win()?
  7. in-game notepad

    About my qsort() version of display_windows(), I noticed the function is sort of timecritical so the question is if the original double loop is faster. There shouldnt be a need to reallocate the space for the array of window_info pointers, but since i dont know if its worth the trouble to change it to become slower I will just let it be at that. It just looked messy when i looked at it earlier, but probably for a good reason
  8. in-game notepad

    OK I thought some more on this and I think this should work and probably also be the right way to do it: The popup window should be a child to notepad window, so I just made this simple change: in notepad.c:display_popup_win() the call to create_window was changed to: popup_win = create_window (win_prompt, notepad_win, 0, popup_x, popup_y, popup_x_len, popup_y_len, ELW_WIN_DEFAULT);
  9. in-game notepad

    I have been trying to figure out why the popup_window not getting topmost and while banging my head against it i rewrote the display_windows() function to use qsort to sort the windows in order to be drawn, instead of the big loops: // qsort function, sorts in ascending order int window_info_compare(const void *p1, const void *p2) { window_info *w1 = *(window_info**)p1; window_info *w2 = *(window_info**)p2; return (w1->order - w2->order); } // new version of display_windows using qsort // NOTE: I have no idea what level is supposed to be doing, it wasnt used // for any noticeable purpose void display_windows(int level) { int i; window_info **wi = NULL; // temp buffer for window info to be sorted wi = calloc(windows_list.num_windows, sizeof(window_info*)); // init temp data for(i=0; i<windows_list.num_windows; i++) wi[i] = &windows_list.window[i]; // qsort them qsort(wi, windows_list.num_windows, sizeof(window_info*), window_info_compare); windows_list.display_level= level; glColor3f(1.0f, 1.0f, 1.0f); // draw everything, already sorted for(i=0; i<windows_list.num_windows; i++) { if (wi[i]->displayed > 0) display_window(wi[i]->window_id); } free(wi); } I have been trying to get the popup window topmost but it seems that the windows are not updated after they are created so it actually is topmost but not redrawn. hmmm strange thing this one, I will throw more random stuff at this and see what happens
  10. in-game notepad

    Is it possible to use return value of the callbacks in a general way? example: 0 - no handling done in callback, safe to use window/widget structure 1 - callback handled the call, but data didnt change so still safe to do more processing 2 - callback handled this and changed data so stop any processing One thing i also noticed when i was testing notepad was that i couldnt find a way to put the popup window (add category) as topmost window. whatever i tried just made it be 'below' the notepad window. We need a way to specify ordering. or maybe even make a new flag in creation that makes window topmost. And yes i tried add a select_window() call but t didnt help. I didnt dvelve deeper into it though.
  11. in-game notepad

    Ok i have tried to search for this bug and here is what i found. Anyone want to check this? // notepad.c:45, exchange function aaccept_popup_window() with this int accept_popup_window () { if (popup_text.len > 0) // added check for no len category notepadAddContinued (popup_text.data); clear_popup_window (); return 1; } //in click_in_window:elwindows.c:1124 // change code to look like this // widgets glPushMatrix(); glTranslatef((float)win->cur_x, (float)win->cur_y, 0.0f); while (W != NULL) { if(mx>W->pos_x && mx<=(W->pos_x+W->len_x) && my>W->pos_y && my<=(W->pos_y+W->len_y)) { if(W->OnClick != NULL) { if (W->OnClick(W,mx - W->pos_x, my - W->pos_y)) { // handled by widget = window can be deleted! // cant loop more, data invalid! glPopMatrix(); return 1; } } } W = W->next; }
  12. crash in free_md2()

    of course silly me. then its some kind of memory problem somewhere. At moment I cant recall what i was doing, it wasnt anything special thats for sure. I also got a crash today while being afk from keyboard 30 minutes, the culprit this time was nvidia drivers and i suspect it tried to do screen updates while my linux box was kicked into screensaver mode. I will keep running under gdb and report whatever problems i find. I got the source from cvs a couple of days ago
  13. crash in free_md2()

    I have been running the cvs client under gdb just in case and I got a crasher yesterday in free_md2() and after stepping through it this seems to be the cause: in free_md2() the first looping through md2_ptr->numFrames it crashes since numFrames seems to be 0. so either there are md2's with no Frames loaded or it is something else causing this. If numFrames indeed can be 0 then it might be a good idea to add a check before looping or accessing offsetFrames[].
×