Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 456 457 [458] 459 460 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909784 times)

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6855 on: January 09, 2015, 11:03:26 am »

snip

I went from 101264ms load times to 80 ms load times.

Thank you.
Logged

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6856 on: January 09, 2015, 12:40:14 pm »

Well that sounds like an improvement!
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6857 on: January 11, 2015, 12:14:08 pm »

So I'm still working on Agora. Right now, it runs on a java applet, which means it won't work unless you edit your java security settings. I'm wondering if theres a way to make that unnecessary. If I purchase a code signing certificate, will that help me get things working? I need the applet to run without the person needing to edit their site exception list and I need it to connect to a webserver without the person editing their java.policy file.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6858 on: January 11, 2015, 01:12:57 pm »

Would something like Spring or Grails work?

I haven't looked at Java much, but presumably there's something that allows you to output HTML, CSS, and JavaScript instead of using an applet.
Logged

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: if self.isCoder(): post() #Programming Thread
« Reply #6859 on: January 11, 2015, 02:39:46 pm »

I don't know. Those both sound very interesting, though. I'll take a look at them.

Hmm. Those both seem more like they're intended for use within a company, because any given application needs to be installed on a computer in order to function.
« Last Edit: January 11, 2015, 03:41:36 pm by Angle »
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Hugehead

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6860 on: January 11, 2015, 06:05:43 pm »

How can you run out of memory? Are you allocating everything on the stack or something?
I have no idea, it just shoots through the damn roof.

I've watched it in task manager.  The program's memory use increases a small amount for each map generated, totaling less than even the IDE uses after a few planets.  Then it'll freeze and the memory use listed in task manager will rise and rise and rise until it hits some specific limit, and then the console will write "memoryError" and the process will stop responding.
If you're not already make sure you output the seed to a file on each run, then when you find a seed that breaks it you'll be able to easily test if it breaks again.
Logged
We're Bay12er's. If there is a bug, we will find it, exploit it, and make a recursive statue out of it. Just look up Planepacked.
When a dwarf enters a martial trance, they become Jedi. Short, drunken Jedi.

ed boy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6861 on: January 12, 2015, 08:25:35 am »

I've got a problem with my C again. In this case, I have a file that I'm opening in "r+" mode, because I want to read it and write to it at the same time. When I feed a list of things to write to it, however, it consistently fails at a certain point. Here's the snippet of code in question:

Code: [Select]
fwrite(&timesinceepoch,sizeof(time_t),1,ptr_datelist);
printf("just tried to write %d\n",timesinceepoch);
fseek(ptr_datelist,-sizeof(time_t),SEEK_CUR);
fread(&prevfiletime,sizeof(time_t),1,ptr_datelist);
printf("actually wrote %d\n",prevfiletime);
Most of the time, this code works, and the value that it says it wrote is the value that it actually wrote. However, there's a certain point where it consistently fails. After a point, the code is supposed to write 1374620400, and actually writes 1364324106. Is there something wrong with my implementation of fwrite and fread, or something weird happening?

EDIT: I;ve discovered that after a point, the fread function somehow fails, but I can't see how. I know that it can read enough bytes to form a time_t object, because I just wrote one to file.
« Last Edit: January 12, 2015, 10:00:58 am by ed boy »
Logged

DJ

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6862 on: January 12, 2015, 11:16:36 am »

How can you run out of memory? Are you allocating everything on the stack or something?
I have no idea, it just shoots through the damn roof.

I've watched it in task manager.  The program's memory use increases a small amount for each map generated, totaling less than even the IDE uses after a few planets.  Then it'll freeze and the memory use listed in task manager will rise and rise and rise until it hits some specific limit, and then the console will write "memoryError" and the process will stop responding.
I'm pretty sure you have a memory leak. Logging *everything* might provide a clue where it is.
Logged
Urist, President has immigrated to your fortress!
Urist, President mandates the Dwarven Bill of Rights.

Cue magma.
Ah, the Magma Carta...

ed boy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6863 on: January 12, 2015, 06:11:53 pm »

Okay, I swear my compiler is fucking with me at this point.

Look at this code:
Code: [Select]
#include<stdio.h>
#include<string.h>

int main()
{
    FILE * examplefile;
    char filepath[128];
    long readvalue;
    long value;

    value=1374620400;     //this does not work
    //value=1374700000;     //this works
    //value=1374600000;     //this works

    strcpy(filepath,"C:\\example");
    examplefile=fopen(filepath,"r+");
    fwrite(&value,sizeof(long),1,examplefile);
    fseek(examplefile,-sizeof(long),SEEK_CUR);
    fread(&readvalue,sizeof(long),1,examplefile);
    printf("Tried to write %d\n",value);
    printf("Read back %d",readvalue);
    fclose(examplefile);
    return 0;
}
There seems to be something special about the value 1374620400 that makes this stop working. The other values work fine, but the specific value and others in a small range around it give wrong answers. Is something fundamentally wrong with my code, or are there shenanigans going on?
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6864 on: January 12, 2015, 06:24:52 pm »

Quote
Code: [Select]
examplefile=fopen(filepath,"r+");

Try opening the file in write mode instead of read mode.   :P  I'm not sure why the other two would work for you, but they certainly crashed on my computer until I set it to write.

Quote
Code: [Select]
examplefile=fopen(filepath,"w+");

edit:  Er, wait.  r+ should be able to be written too as long as the file already exists. 

Um, I dunno.  Your code works fine on my computer now that the file exists.
« Last Edit: January 12, 2015, 06:30:46 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

ed boy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6865 on: January 12, 2015, 06:34:27 pm »

Even when I modify it to make sure the file exists, it still gives problems on my end.

Code: [Select]
#include<stdio.h>
#include<string.h>

int main()
{
    FILE * examplefile;
    char filepath[128];
    long readvalue;
    long value;

    value=1374620400;     //this does not work
    //value=1374700000;     //this works
    //value=1374600000;     //this works

    strcpy(filepath,"C:\\temp\\example");
    //let's create a blank file first to avoid problems
    examplefile=fopen(filepath,"w");
    fclose(examplefile);
    //now let's actually test it
    examplefile=fopen(filepath,"r+");
    fwrite(&value,sizeof(long),1,examplefile);
    fseek(examplefile,-sizeof(long),SEEK_CUR);
    fread(&readvalue,sizeof(long),1,examplefile);
    printf("Tried to write %d\n",value);
    printf("Read back %d",readvalue);
    fclose(examplefile);
    return 0;
}
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6866 on: January 12, 2015, 06:40:32 pm »

There seems to be something special about the value 1374620400 that makes this stop working. The other values work fine, but the specific value and others in a small range around it give wrong answers. Is something fundamentally wrong with my code, or are there shenanigans going on?

Have you ensured that what was written is what it says was written? It works for me as well, though I had to change %d to %ld.
Logged

ed boy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6867 on: January 12, 2015, 06:43:34 pm »

Have you ensured that what was written is what it says was written? It works for me as well, though I had to change %d to %ld.
Yep, it reads back a different value, it's not just printing the wrong thing.

Code: [Select]
#include<stdio.h>
#include<string.h>

int main()
{
    FILE * examplefile;
    char filepath[128];
    long readvalue;
    long value;

    value=1374620400;     //this does not work
    //value=1374700000;     //this works
    //value=1374600000;     //this works

    strcpy(filepath,"C:\\temp\\example");
    //let's create a blank file first to avoid problems
    examplefile=fopen(filepath,"w");
    fclose(examplefile);
    //now let's actually test it
    examplefile=fopen(filepath,"r+");
    fwrite(&value,sizeof(long),1,examplefile);
    fseek(examplefile,-sizeof(long),SEEK_CUR);
    fread(&readvalue,sizeof(long),1,examplefile);
    printf("Tried to write %d\n",value);
    printf("Read back %d\n",readvalue);
    if (readvalue!=value)
    {
        printf("What we wrote and read was not the same\n");
    }
    fclose(examplefile);
    return 0;
}
I'll try it on a different compiler, and see if that helps.
Logged

ed boy

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6868 on: January 12, 2015, 06:54:59 pm »

okay, I tried it with a different compiler, and it's still not working.

Could it be something wrong with my computer?
Logged

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #6869 on: January 12, 2015, 07:02:50 pm »

Hmm, does it work if you do:

fseek(examplefile,0,SEEK_SET);

instead of

fseek(examplefile,-sizeof(long),SEEK_CUR);

Edit---------------------------------:

I did some random googling and maybe you need to specify it as a binary file on your platform? 

fopen(filepath,"rb+");
« Last Edit: January 12, 2015, 07:08:48 pm by Levi »
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout
Pages: 1 ... 456 457 [458] 459 460 ... 796