Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 544 545 [546] 547 548 ... 796

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

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8175 on: October 12, 2015, 12:30:49 pm »

Code: [Select]
error: cannot dynamic_cast '((ProgramManager*)this)->ProgramManager::EMan.EntityManager::EntityContainer.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<int, Entity*, std::less<int>, std::allocator<std::pair<const int, Entity*> > >((*(const key_type*)(&((ProgramManager*)this)->ProgramManager::PlayerID)))' (of type 'std::map<int, Entity*>::mapped_type {aka class Entity*}') to type 'class Player*' (source type is not polymorphic)
Do I perhaps have to modify the classes themselves somehow?
Logged

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8176 on: October 12, 2015, 01:04:48 pm »

It doesn't know that Entity is polymorphic. Entity needs to have a virtual function.
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

HavingPhun

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8177 on: October 12, 2015, 01:40:36 pm »

Well, that was strangely simple. All I had to do was make the destructor for "Entity" virtual. Thanks everyone.
Logged

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
    • Demon Legend
Re: if self.isCoder(): post() #Programming Thread
« Reply #8178 on: October 12, 2015, 09:31:25 pm »

Been taking a small break from my big stuff and doing small things, funtimes.  Made an IRC bot using winsock today, got it working on twitch (and threaded and all that)... and now poking around the Twitter API.  Think I can make something that tweets the last timeline tweet of a specified account to an IRC channel.
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Also working on THIS! Farworld Pioneers
Mastodon

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8179 on: October 13, 2015, 04:48:52 am »

I finally managed to get Arch to install successfully. I also managed to connect to my school's wifi, which was easier said than done. Turns out that they not only use WPA2-Enterprise PEAP MSCHAPv2 (the earlier version, not the current) but also disable certificate authentication. No wonder that it took less time to connect writing my own network configs over using NetworkManager back when I ran Mint.
This sounds like a facepalm moment.
So, yeah.
*facepalm*
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #8180 on: October 13, 2015, 01:22:13 pm »

This GUI library requires that I use function object callbacks with the signature "void()", but I need to set the callback to a member function, which means I need to std::bind it to a raw pointer. The problem is that, seemingly at random, the pointer gets invalidated by something. So the function gets called, but the "this" argument is pointing at some garbage data and I end up getting a memory access error. I only ever create a single instance of the class in question, so I have no idea what could be causing its location in memory to shift around.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

TheBiggerFish

  • Bay Watcher
  • Somewhere around here.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8181 on: October 13, 2015, 04:34:52 pm »

I finally managed to get Arch to install successfully. I also managed to connect to my school's wifi, which was easier said than done. Turns out that they not only use WPA2-Enterprise PEAP MSCHAPv2 (the earlier version, not the current) but also disable certificate authentication. No wonder that it took less time to connect writing my own network configs over using NetworkManager back when I ran Mint.
This sounds like a facepalm moment.
So, yeah.
*facepalm*

Nah, more that this school does not know how to do a proper wireless network correctly.
Like I said, facepalm moment.  Or headdesk.
Logged
Sigtext

It has been determined that Trump is an average unladen swallow travelling northbound at his maximum sustainable speed of -3 Obama-cubits per second in the middle of a class 3 hurricane.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8182 on: October 13, 2015, 06:29:13 pm »

This GUI library requires that I use function object callbacks with the signature "void()", but I need to set the callback to a member function, which means I need to std::bind it to a raw pointer. The problem is that, seemingly at random, the pointer gets invalidated by something. So the function gets called, but the "this" argument is pointing at some garbage data and I end up getting a memory access error. I only ever create a single instance of the class in question, so I have no idea what could be causing its location in memory to shift around.

My guess is that it's memory corruption elsewhere.  Are you on Linux?  I'd try Valgrind on it to see if it recognizes any invalid memory writes.  If you're on Windows I think Visual Studio may have something similar now, but maybe not in the free version.
Logged
Through pain, I find wisdom.

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8183 on: October 14, 2015, 06:32:17 pm »

Spoiler (click to show/hide)

Making a rock,paper, scissors game and I can't find where my error is. Compilers talking about a missing semicolon but I can't find that anywhere.
Logged

Moghjubar

  • Bay Watcher
  • Science gets you to space.
    • View Profile
    • Demon Legend
Re: if self.isCoder(): post() #Programming Thread
« Reply #8184 on: October 14, 2015, 06:50:29 pm »

Should be able to find it in build message, but if not... try this:

Use /* */ and comment out the bottom half of your code.  If you still get the error, its in the top section probably.
Logged
Steam ID
Making things in Unity
Current Project: Demon Legend
Also working on THIS! Farworld Pioneers
Mastodon

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8185 on: October 14, 2015, 07:22:17 pm »

Found it!

I was missing a ) statement on one of the ifs.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8186 on: October 14, 2015, 10:49:52 pm »

This GUI library requires that I use function object callbacks with the signature "void()", but I need to set the callback to a member function, which means I need to std::bind it to a raw pointer. The problem is that, seemingly at random, the pointer gets invalidated by something. So the function gets called, but the "this" argument is pointing at some garbage data and I end up getting a memory access error. I only ever create a single instance of the class in question, so I have no idea what could be causing its location in memory to shift around.

c++ I'm guessing. Are you using the new keyword to create the object in the heap? if you do that and store the returned pointer from new, it should never be changed.

Gatleos

  • Bay Watcher
  • Mournhold... City of Light... City of MAGIC!
    • View Profile
    • Someone Sig This
Re: if self.isCoder(): post() #Programming Thread
« Reply #8187 on: October 15, 2015, 10:56:05 am »

c++ I'm guessing. Are you using the new keyword to create the object in the heap? if you do that and store the returned pointer from new, it should never be changed.

Yep, and it's SFGUI, which has a policy that all objects in the library can only be created as shared_ptrs. All widgets have a Create function like this (see the first function), so those should all be allocated dynamically on the heap. My own class, which contains these widgets, is a singleton for testing purposes, and the only instance of it is created like this:

Code: [Select]
shared_ptr<DeployGroupMenu> DeployGroupMenu::instance() {
static auto dgm = make_shared<DeployGroupMenu>(DeployGroupMenu());
return dgm;
}

That class is the one that I keep losing a pointer to, and I still can't find a pattern in when it happens. It seemed to happen consistently whenever I changed the text in a certain label, which caused the window's hierarchy of widgets to resize itself. The weirdest part is that the input that caused this resize also caused other member function callbacks to occur, but only this specific callback seemed to have a garbage "this" pointer when it was executed. I guess I just have to test a few more things.

My guess is that it's memory corruption elsewhere.  Are you on Linux?  I'd try Valgrind on it to see if it recognizes any invalid memory writes.  If you're on Windows I think Visual Studio may have something similar now, but maybe not in the free version.

I do have access to a linux machine, so maybe I'll give valgrind a try.
Logged
Think of it like Sim City, except with rival mayors that seek to destroy your citizens by arming legions of homeless people and sending them to attack you.
Quote from: Moonshadow101
it would be funny to see babies spontaneously combust
Gat HQ (Sigtext)
++U+U++ // ,.,.@UUUUUUUU

RoguelikeRazuka

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8188 on: October 15, 2015, 02:27:13 pm »

You won't believe guys but some say programming languages are simply a form of representation of algorithms, and in order to become a programmer I should focus on learning algorithms rather than on learning a programming language. Are they completely right? Whether they are or not, where do I start from? Which books (or another resources) on algorithms would you guys particularly suggest and which algorithms is it necessary to know for every programmer?
« Last Edit: October 15, 2015, 03:33:40 pm by RoguelikeRazuka »
Logged

3man75

  • Bay Watcher
  • I will fire this rocket
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #8189 on: October 15, 2015, 02:28:25 pm »

Spoiler (click to show/hide)

Found a problem that after a tie it won't check for incorect responces (Because it's already been done). Something else happens when I swtich them around.

Another one is that if I switch the two loops around then something happens that after I've tied and then input wrong statements that my program will accept a wrong statement before it simply just dosen't declare a winner. This is C++ btw.
Logged
Pages: 1 ... 544 545 [546] 547 548 ... 796