Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411430 Posts in 69363 Topics- by 58416 Members - Latest Member: JamesAGreen

April 20, 2024, 02:34:46 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 194 195 [196] 197 198 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 738293 times)
Geti
Level 10
*****



View Profile WWW
« Reply #3900 on: January 29, 2013, 03:18:07 AM »

Almost surprisingly, not that I've seen yet. Apparently angles being accurate and a few other issues was unimportant for anything immediately visible. We'll see if something breaks in a month Concerned

stuffing around with win32 all day to "quickly make a simple and minimal launcher for moonman". big mistake.
Heh, aw. GUI stuff is so easy to waste time on :/
Logged

Klaim
Level 10
*****



View Profile WWW
« Reply #3901 on: January 29, 2013, 04:43:44 AM »

Memory leaks. Memory leaks everywhere.
C/C++?

You can memory leak with almost any language.


Yeah, but much more easily with C/C++. Avoiding memory leaks in C(++) is a trained skill in itself Tongue

If you don't program in C in a C++ program, no memory leak.
The problem is more that when you learn it most of the time you learn to manipulate pointers, which is the source of memory leaks. While if you learn it properly at the beginning, not using pointers util you have to, then no memory leaks appear. Like, I didn't have any for years once I learnt that I learnt it totally wrong. Now as soon as I see new and delete in a source code, I'm getting suspicious.
Logged

_Tommo_
Level 8
***


frn frn frn


View Profile WWW
« Reply #3902 on: January 29, 2013, 05:00:25 AM »

If you don't program in C in a C++ program, no memory leak.
The problem is more that when you learn it most of the time you learn to manipulate pointers, which is the source of memory leaks. While if you learn it properly at the beginning, not using pointers util you have to, then no memory leaks appear. Like, I didn't have any for years once I learnt that I learnt it totally wrong. Now as soon as I see new and delete in a source code, I'm getting suspicious.

this.
And Get() - Release() reference pointer style is even worse because it attempts to solve the problem but actually makes it worse (you still have to remember to Release(), but not once - EACH time you Get() something!).
Logged

rivon
Level 10
*****



View Profile
« Reply #3903 on: January 29, 2013, 05:56:56 AM »

I just program something, then run Valgrind on it and fix the leaks. Rinse and repeat Smiley
Logged
Klaim
Level 10
*****



View Profile WWW
« Reply #3904 on: January 29, 2013, 09:45:57 AM »

I just program something, then run Valgrind on it and fix the leaks. Rinse and repeat Smiley

I actually do something like this (but on Windows so no valgrind) which is why I say I didn't have leaks for years. Only on long projects thought. I even sometime write leaks to make sure it's not the tool that don't work anymore for some reasons.

(actually there are leaks sometimes, mostly due to libraries not releasing automatically their resources, like protobuf, so you have to do it explicitely by calling some functions if you think it's necessary - I do because otherwise I can't catch mine)
Logged

Gregg Williams
Level 10
*****


Retromite code daemon


View Profile WWW
« Reply #3905 on: January 29, 2013, 10:36:12 AM »

I just write code where allocation and deletion is usually 100% contained to some sort of level initialization/cleanup.  Don't remember the last time I had a real memory leak.
Logged

epcc
Level 1
*


View Profile
« Reply #3906 on: January 30, 2013, 07:42:58 AM »

I'm creating all game objects with new and they are automatically added to level object list.
to delete them, I set a field called mustdelete to true and at the end of every frame the level object removes them from the list and deletes them. All other objects are either created on stack or created only once, at game start. Haven't had memory leaks with game objects since.


Now I'm rewriting level format and already having doubts.
There's going to be maybe 20 functions that look almost the same, the only difference is the object name and sometimes an extra parameter.
Is there some better solution than that?
Code:
static int con_LuaObject(lua_State* L)
{
    TBasicInfo basicinfo;

    TLuaObject* ptr=new TLuaObject(basicinfo.pos,basicinfo.angle,basicinfo.type);
    CON_END
}
All these functions go to a lua list, so every object calls the correct constructor with correct arguments according to their type.
CON_END expands to
Code:
#define CON_END ptr->color=basicinfo.col;\
InitObjectName(L,ptr);\
ptr->GetLuaObject(L);\
return 1;
Logged

Schrompf
Level 9
****

C++ professional, game dev sparetime


View Profile WWW
« Reply #3907 on: January 30, 2013, 08:08:25 AM »

Make it a template. You'll still need to register all instances of this template function separately with LUA, but at least you only have to write it once.
Logged

Snake World, multiplayer worm eats stuff and grows DevLog
epcc
Level 1
*


View Profile
« Reply #3908 on: January 30, 2013, 08:50:28 AM »

The problem is, that some objects need additional parameters. For example:

Code:
static int con_Door(lua_State* L)
{
    TBasicInfo basicinfo;

    int frame=li_GetTableInt("frame"); <- this one right here, for example.
    TDoor* ptr=new TDoor(basicinfo.pos,basicinfo.angle,frame);
    CON_END
}
This makes any templating hard.
Logged

eigenbom
Level 10
*****


@eigenbom


View Profile WWW
« Reply #3909 on: January 30, 2013, 12:37:03 PM »

@epcc write a simple code generator?
Logged

BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #3910 on: January 30, 2013, 02:06:31 PM »

imho it's not wise to use C++ inheritance when you are binding to Lua - why not handle that sort of logic in Lua, where it is easier and more flexible.

Anwyay, given what you've got, use SWIG to quickly generate bindings from C++ to Lua - half the time all SWIG needs is the header file, and it does the rest.
Logged
epcc
Level 1
*


View Profile
« Reply #3911 on: February 01, 2013, 04:53:53 AM »

SWIG is just what I need. I should have used it from the start, instead of manually writing my own.
It's hard to estimate if the work will eventually get mechanical enough that it could be done by a computr
Logged

eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile
« Reply #3912 on: February 01, 2013, 01:51:49 PM »

Plugging my own tutorial, look in the TUTORIAL sections on here, I wrote a system that will handle most LUA-C++ things transparently with no additional runtime cost. It's really quite easy once you wrap a few things in templates and MACROS. Yums.
Logged

I make Mysterious Castle, a Tactics-Roguelike
Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #3913 on: February 02, 2013, 05:08:23 AM »

Perhaps this should go in the Happy Programmer thread since I fixed my problem, but I'm still more grumpy than happy.

Apparently, in Unity using the XMLDocument class works perfectly fine with DTD when in the editor, but .NET throw a NotImplementedException when it is actually built.  Instead of changing all of my xml parsing to use a format that ignores DTD (since the supposed ways to make XMLDocument ignore DTD don't work), I just removed the DTD from the xml file. 
Logged
Belimoth
Level 10
*****


high-heeled cyberbully


View Profile
« Reply #3914 on: February 03, 2013, 11:41:32 PM »

I have gotten no work done in the last two days because I can not get anything to render.
I can get things to render if I comment out the creation of any entities:
Here is the code for the entity class:

Code:
Class MyEntity Extends AbuEntity
Field x:Int, y:Int
End

IT DOESN'T EVEN DO ANYTHING Hand Shake Left Angry Hand Shake Right
Logged

Muz
Level 10
*****


View Profile
« Reply #3915 on: February 08, 2013, 02:21:07 AM »

Merging new code into some other new code.

sometimes programming with two people is slower than one person doing it alone. Only 33 out of 43 left to do...
Logged
skew
Level 0
**


codin flash and flashin code


View Profile
« Reply #3916 on: February 08, 2013, 01:14:40 PM »

writing php the whole week... while thinking about how much better the code would be in python  Apoplectic
Logged
Eendhoorn
Level 6
*

Quak


View Profile
« Reply #3917 on: February 08, 2013, 03:49:18 PM »

I absolutely hate the unity asset store. I always loved how generous and helpful programming communities are to each other. If I have an issue, or just don't want to reinvent the wheel with XNA or any other framework, I could search and find someone who would be generous enough to share his framework/solution for free.

But every-goddamn-thing is paid in the unity asset store. And it's pretty damn expensive aswell. A simple 2D tilegrid plugin costs $50.
Logged

Geti
Level 10
*****



View Profile WWW
« Reply #3918 on: February 09, 2013, 05:46:04 PM »

writing php the whole week... while thinking about how much better the code would be in python  Apoplectic
Why did you have to do it in PHP?
Logged

sublinimal
Level 8
***



View Profile
« Reply #3919 on: February 11, 2013, 04:33:50 AM »

C++ woes. A template function didn't compile, so I was told to move it into the header... which revealed some circular dependency issues... that only got worse as I started fixing them.

Logged
Pages: 1 ... 194 195 [196] 197 198 ... 295
Print
Jump to:  

Theme orange-lt created by panic