Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411415 Posts in 69361 Topics- by 58415 Members - Latest Member: sophi_26

April 16, 2024, 02:56:16 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)The grumpy old programmer room
Pages: 1 ... 109 110 [111] 112 113 ... 295
Print
Author Topic: The grumpy old programmer room  (Read 737973 times)
LemonScented
Level 7
**



View Profile
« Reply #2200 on: May 26, 2011, 06:18:19 PM »

I ever mention how annoying coding audio is?


Get anything wrong and it PHYSICALLY HURTS your ears.
Using headphones while audio coding is a baaad idea in my experience

I hear ya.

Or, rather, I hear an incessant constant low-level screeching that never goes away, but sometimes gets louder when I'm having nightmares Epileptic
Logged

mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2201 on: May 26, 2011, 06:22:07 PM »

OMG typedef I miss you

I assume this is JavaScript? Because if it's Flash I'm going to have to shoot you. Tongue

It's ActionScript! How the heck am I supposed to be doing this?
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Mipe
Level 10
*****


Migrating to imagination.


View Profile
« Reply #2202 on: May 26, 2011, 10:22:44 PM »

Not game dev, but... I developed a WordPress plugin for internal use at the company I work for (until the end of month, whee). When I finished it, I thought it was pretty much complete and stable. Uploaded it and patted myself on the back on job well done.

Turns out I was woefully wrong.

Code:
add_filter('the_content', 'gsp_firstpostad');

global $gsp_counter;
function gsp_firstpostad($content){
if(in_the_loop()){
global $gsp_counter;
                $gsp_counter++;
if($gsp_counter==1){
    $data= get_option('GSP_FIRSTPOSTAD');
            $ad_code = stripslashes($data['gsp_firstpostad']);
    $content= $ad_code.$content;
                    return $content;
}
}
}

So, this basically inserts Google Ad code into the first article that occurs on any page (first article in the loop). Now, the dumb thing is that Wordpress filters take data as a parameter, modify it and then return it. I forgot about the part about having to always return the data, modified or not. So articles except for the first one had no content at all, as it all was gobbled up by the filter.

Gah. Solution? Move the return $content; after in_the_loop if statement. That way it always returns $content, whether it is modified or not.

Lesson learned? Test solutions thoroughly before embarrassing oneself in front of everyone.
Logged
increpare
Guest
« Reply #2203 on: May 27, 2011, 04:00:56 PM »

I love you guys (+girls)
Logged
st33d
Guest
« Reply #2204 on: May 27, 2011, 05:40:58 PM »

ATTENTION

Okay. I've split the discussion into a new topic called Multidimensional Arrays:

http://forums.tigsource.com/index.php?topic=19774.msg565212#msg565212

Further discussion can be carried on there.

Apologies if a post is out of order or out of context. Just msg me and I'll try to fix it.

Please don't bring the topic back here, it's a pain in the arse to move posts around and it might result in a post getting lost.
Logged
Glaiel-Gamer
Guest
« Reply #2205 on: May 27, 2011, 05:45:58 PM »

on a new grumpy note: ugg I think I have a threading-related deadlock bug. URGH. Across 3 threads and involving at least 3 mutexes

edit: 4 threads actually






A JOKE BASED ON THIS SITUATION:

 4 threads and 3 mutexes walk into a bar. Thread 1 says "I'll have a... ... ... ... ... ... ... ... ... ..."
Logged
bateleur
Level 10
*****



View Profile
« Reply #2206 on: May 27, 2011, 11:51:59 PM »

on a new grumpy note: ugg I think I have a threading-related deadlock bug. URGH. Across 3 threads and involving at least 3 mutexes

edit: 4 threads actually

Pro tip: merge your mutex locks. The natural inclination of most programmers is to minimise blocking by having resources A, B and C protected by three separate locks. However, in cases where two threads both make use of two or more locks it often makes sense (and can make your program run better) to replace them with a single lock. No deadlocks ever again!

For more complex setups (which you should almost never have unless you're writing an OS kernel) you can get similar results by giving your locks a hierarchy. So for locks A, B, C you have a rule that any thread which ever locks both A and B at the same time must always acquire A first and B second. Similarly, B must always be acquired before C.

These sorts of designs may sound limiting, but if you don't take these sorts of steps it isn't the deadlocks you spot (never mind experience) which you have to fear... it's the ones you won't. You rely on testing alone, because some deadlocks will arise from (for example) race conditions that happen only on some machines and not others.
Logged

pgil
Guest
« Reply #2207 on: May 28, 2011, 06:59:07 AM »

Code:
import net.flashpunk.Entity;
public class obEditor extends Entity
{
private var ecollide:Entity;
private var collideWithTypes:Array = new Array("solid","none", "water","goal","player","sheep","scroll");

public static function delete_at(X:int, Y:int):void {
ecollide = collideTypes(collideWithTypes, X, Y);
//trace(c);
if (ecollide != null) FP.world.remove(ecollide);
}
        }


Code:
(150): col: 4 Error: Access of undefined property ecollide.
(150): col: 15 Error: Call to a possibly undefined method collideTypes.
(150): col: 28 Error: Access of undefined property collideWithTypes.
(152): col: 8 Error: Access of undefined property ecollide.
(152): col: 42 Error: Access of undefined property ecollide.

Am I stupid?  Seriously.... This code is not complicated, and I don't see anything wrong with it.  So... I must be stupid, right?
Logged
increpare
Guest
« Reply #2208 on: May 28, 2011, 07:07:28 AM »

static functions can't access member variables... you want to make the function not static, or make the variables static...
Logged
pgil
Guest
« Reply #2209 on: May 28, 2011, 07:21:48 AM »

Ok... That makes sense.

What about this?

Code:
import net.flashpunk.Entity;

public class obEditor extends Entity
{
public static var ecollide:Entity;
public static var collideWithTypes:Array = new Array("solid","none", "water","goal","player","sheep","scroll");

public static function delete_at(X:int, Y:int):void {
ecollide = collideTypes(collideWithTypes, X, Y);
//trace(c);
if (ecollide != null) FP.world.remove(ecollide);
}
}
Code:
(150): col: 15 Error: Call to a possibly undefined method collideTypes.

collideTypes is a public method of Flashpunk's Entity calss.  I started getting this error after I changed delet_at to a static function.  It needs to be static so I can call it from another class... I... think?
Logged
increpare
Guest
« Reply #2210 on: May 28, 2011, 08:37:50 AM »

Quote
collideTypes is a public method of Flashpunk's Entity calss.  I started getting this error after I changed delet_at to a static function.  It needs to be static so I can call it from another class... I... think?

It needs to be public so you can call it from another class.  Static means you can call it without have a particular instance of that class to hand, so  if it's public + static I can do

Code:
obEditor.delete_at(0,1)

if it's public + not static I need an obEditor instance

Code:
var myOb:obEditor = whatever;
myOb.delete_at(0,1);

you're getting the collideTypes error because collideTypes is presumably not static, so you need an instance of that object to call it on.  You can't call non-static methods from static methods (without an instance of the class).

(you seem a bit shakey on object oriented stuff - you might want to read up a bit?)
Logged
pgil
Guest
« Reply #2211 on: May 28, 2011, 09:35:53 AM »

(you seem a bit shakey on object oriented stuff - you might want to read up a bit?)
I know.  I just jumped into porting a fairly complex game as my first real Flash project.  I feel like I'm writing a novel without knowing how to read  Embarrassed
Logged
increpare
Guest
« Reply #2212 on: May 28, 2011, 10:55:25 AM »

(you seem a bit shakey on object oriented stuff - you might want to read up a bit?)
I know.  I just jumped into porting a fairly complex game as my first real Flash project.  I feel like I'm writing a novel without knowing how to read  Embarrassed
Heheh.  Porting from what language? Did you write the original project?
Logged
Glaiel-Gamer
Guest
« Reply #2213 on: May 28, 2011, 11:31:58 AM »

Pro tip: merge your mutex locks. The natural inclination of most programmers is to minimise blocking by having resources A, B and C protected by three separate locks. However, in cases where two threads both make use of two or more locks it often makes sense (and can make your program run better) to replace them with a single lock. No deadlocks ever again!

Ya I'm just a noob at multithreading code right now so a few classes internally have their own mutex (specifically the memory-mapped file cache, individual audio streams, and an audio controller) and to be "safe" I just "protected" entire blocks of code with mutex locks.

I fixed it by reworking it to only lock the couple of lines that needed to be locked and making sure I wasn't locking code that would lock another mutex internally. Seems to have worked.
Logged
pgil
Guest
« Reply #2214 on: May 28, 2011, 12:01:13 PM »

(you seem a bit shakey on object oriented stuff - you might want to read up a bit?)
I know.  I just jumped into porting a fairly complex game as my first real Flash project.  I feel like I'm writing a novel without knowing how to read  Embarrassed
Heheh.  Porting from what language? Did you write the original project?
Game Maker/GML... It's this sheep game that I made last year. Really, the only complicated thing in the game (logic-wise) is A* pathfinding, which I'd like to figure out myself.  But this is the first object-oriented language I've used, and I think I skipped over some basics of as3 in order to get to the fun stuff... I think I'm gradually getting used to it though.  I've learned a lot since I started working on this just a few days ago.
Logged
increpare
Guest
« Reply #2215 on: May 28, 2011, 12:04:19 PM »

Game Maker/GML... It's this sheep game that I made last year. Really, the only complicated thing in the game (logic-wise) is A* pathfinding, which I'd like to figure out myself.  But this is the first object-oriented language I've used, and I think I skipped over some basics of as3 in order to get to the fun stuff... I think I'm gradually getting used to it though.  I've learned a lot since I started working on this just a few days ago.
Ah cool.  Yeah, work through the confusion a bit, don't be afraid to read up stuff online if you're getting frustrated, and you'll be fine eventually : )
Logged
bateleur
Level 10
*****



View Profile
« Reply #2216 on: May 28, 2011, 01:07:15 PM »

I fixed it by reworking it to only lock the couple of lines that needed to be locked and making sure I wasn't locking code that would lock another mutex internally. Seems to have worked.

Hurrah! Good work! Beer!
Logged

mcc
Level 10
*****


glitch


View Profile WWW
« Reply #2217 on: May 28, 2011, 02:17:07 PM »

Pro tip: merge your mutex locks. The natural inclination of most programmers is to minimise blocking by having resources A, B and C protected by three separate locks. However, in cases where two threads both make use of two or more locks it often makes sense (and can make your program run better) to replace them with a single lock. No deadlocks ever again!

Ya I'm just a noob at multithreading code right now so a few classes internally have their own mutex (specifically the memory-mapped file cache, individual audio streams, and an audio controller) and to be "safe" I just "protected" entire blocks of code with mutex locks.

I fixed it by reworking it to only lock the couple of lines that needed to be locked and making sure I wasn't locking code that would lock another mutex internally. Seems to have worked.
Yeah "minimize the size of your critical sections" is always an excellent plan
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
_Tommo_
Level 8
***


frn frn frn


View Profile WWW
« Reply #2218 on: May 30, 2011, 10:44:59 AM »

"semget error: No space left on device"

And I'm trying to allocate only a measly semaphore. There's some random app that has filled the semaphore buffer, and my own one (that only requires private semaphores) has to crash.
This really has no sense at all, you got to love UNIX.
Will try to use pthreads.
Logged

Triplefox
Level 9
****



View Profile WWW
« Reply #2219 on: May 30, 2011, 02:32:21 PM »

Argh, ran into some compiler/JIT heisenbug. A certain variable goes null depending on arbitrary changes elsewhere in the source code.

Not the first time this has happened with Flash Angry
Logged

Pages: 1 ... 109 110 [111] 112 113 ... 295
Print
Jump to:  

Theme orange-lt created by panic