If you're using visual studio run rebuild solution
[QUOTE=Chandler;23234246]If you're using visual studio run rebuild solution[/QUOTE]
I can't find the build menu in VS2010...
Generate > Rebuild Solution
-Snip-
Derp
[QUOTE=pikzen;23235817]Generate > Rebuild Solution[/QUOTE]
I think you have to activate Tools > Settings > Expert Settings first.
wow, VS2010 sounds way too complicated
Okay, after some messing around with winsock, I think I have a better understanding :D.
Anyways, is it find to do something like
[code] for (int i = 0; i < size; )
{
len = Tcp.Client.Receive(buff, i, size-i, SocketFlags.None);
i += len;
}[/code]
Basically it keeps calling receive until the entire chunk is received.
[B]Edit:[/B]
Sending streams with priorities is working :D
[img]http://i28.tinypic.com/ws7kno.jpg[/img]
Just need to add a max size.
[QUOTE=layla;23228084]this hobby/profession obviously isn't for you.[/QUOTE]
What? Because I said, "Programming ;__;"?
[QUOTE=high;23229974]So then why doesn't it block when I call send with a 50mb buffer. But it does when I call send with a 1 byte buffer after the 50mb?[/QUOTE]
Look at the documentation of send()'s return value. It doesn't necessarily send (copy into the kernel buffer) all the bytes you asked it to; the return value tells you how many bytes it accepted, and any excess will need to be passed to another send() call later.
If you try to send() 50 megabytes, it can't accept all that at once, but it accepts as much as it can, filling the kernel's send buffer. Then when you send() again immediately afterward, the buffer is full so it blocks.
[QUOTE=Wyzard;23240892]Look at the documentation of send()'s return value. It doesn't necessarily send (copy into the kernel buffer) all the bytes you asked it to; the return value tells you how many bytes it accepted, and any excess will need to be passed to another send() call later.
If you try to send() 50 megabytes, it can't accept all that at once, but it accepts as much as it can, filling the kernel's send buffer. Then when you send() again immediately afterward, the buffer is full so it blocks.[/QUOTE]
It sends the entire 50mb though.
What value does send() return?
[QUOTE=Wyzard;23241706]What value does send() return?[/QUOTE]
send returns the 50mb and the recv on the server returns 50mb. And no it is not localhost.
Dunno then. It's within the bounds of how send() is specified to behave, but it's not what I would've expected. Are you sure the first send() call isn't blocking? How are you determining that?
I have it output how much it sent after the call using the return value.
I mean how you're determining whether send() blocked or not. That's not something a process can normally determine about itself, afaik.
Edit: Solved it. So don't bother thinking about it. Solution at the bottom.
I've never done enums in C++, and I'm not sure how too use them properly.
I'm doing a Qt application, and Qt's enums are used like Qt::Monday, but it's part of an enum named DayOfWeek and is part of the Qt Namespace.
I tried something similar like:
[cpp]
namespace KJ
{
enum OptionKeys_String
{
FOO
};
enum OptionKeys_Bool
{
BAR
};
enum OptionKeys_Int
{
BAZ
};
};
[/cpp]
And if I try to use it as a function paramter like:
[cpp]
fooFunction(KJ::BAR);
[/cpp]
I get this error:
[code]
error: expected primary-expression before ')' token
[/code]
But if I do:
[cpp]
fooFunction(KJ::OptionKeys_Bool::BAR);
[/cpp]
I get:
[code]
error: 'KJ::OptionKeys_Bool' is not a class or namespace
[/code]
Somehow I've never worked with namespaces or enums in C++. :v:
I don't use C++ much, and I've just never had a need for a namespace.
[editline]10:47PM[/editline]
The fooFunction is declared this way:
[cpp]
static bool fooFunction(KJ::OptionsKey_Bool o);
[/cpp]
[editline]10:50PM[/editline]
Oh fuck it. I had an extraneous , left over when I called the function so it ended up like fooFunction(KJ::BAR,); And I didn't even notice. :colbert:
[QUOTE=shill le 2nd;23237985]wow, VS2010 sounds way too complicated[/QUOTE]
They're making it sound like that, but I don't have a clue what they're talking about. What's wrong with pressing the little button on the toolbar? :v:
[QUOTE=pikzen;23231207]Argh, I'm in trouble with a small C# game..
I've got this form :
[img]http://dl.dropbox.com/u/5502511/Dev/TG_1.png[/img]
[img]http://dl.dropbox.com/u/5502511/Dev/TG_2.png[/img]
There's a timer (game_Timer) and a statusstrip (stats_StatusStrip)
Basically, a timer fills it with a letter every 800ms, and typing this letter should make it disappear. Of course, the letter does not disappears.
Form1.cs
[cpp]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TypingGame
{
public partial class Main_Form : Form
{
Random random = new Random();
Stats stats = new Stats();
public Main_Form()
{
InitializeComponent();
}
private void game_Timer_Tick(object sender, EventArgs e)
{
// Add a random Key to the List Box
letters_ListBox.Items.Add((Keys)random.Next(65, 90));
if (letters_ListBox.Items.Count > 7)
{
letters_ListBox.Items.Clear();
letters_ListBox.Items.Add("Game over.");
game_Timer.Stop();
start_Button.Text = "Restart";
}
}
private void Main_Form_KeyDown(object sender, KeyEventArgs e)
{
if (letters_ListBox.Items.Contains(e.KeyValue))
{
// If the key is in the list, remove it
letters_ListBox.Items.Remove(e.KeyValue);
letters_ListBox.Refresh();
if (game_Timer.Interval > 800)
game_Timer.Interval -= 25;
if (game_Timer.Interval > 400)
game_Timer.Interval -= 15;
if (game_Timer.Interval < 200)
game_Timer.Interval -= 5;
difficulty_ProgressBar.Value = 1200 - game_Timer.Interval;
stats.Update(true);
}
else
{
// You missed. No update, no points.
stats.Update(false);
}
// Update the labels.
correct_Label.Text = "Correct: " + stats.correct;
missed_Label.Text = "Missed: " + stats.missed;
total_Label.Text = "Total: " + stats.total;
accuracy_Label.Text = "Accuracy: " + stats.accuracy + "%";
// Find a way to keep track of time elapsed here
}
private void start_Button_Click(object sender, EventArgs e)
{
game_Timer.Start();
letters_ListBox.Items.Clear();
}
}
}
[/cpp]
Stats.cs
[cpp]
namespace TypingGame
{
class Stats
{
public int total = 0;
public int correct = 0;
public int missed = 0;
public int accuracy = 0;
public int totalTime = 1200;
public void Update(bool correctKey)
{
if (correctKey)
{
correct++;
}
else
{
missed++;
}
accuracy = 100 * correct / (missed + correct);
}
}
}
[/cpp]
What is wrong with it ?[/QUOTE]
Any idea ?
[editline]04:03PM[/editline]
letters_ListBox.Items.RemoveAt(index number); does not works. I'm guessing that's more a problem with my ListBox. I'll try by converting it to UTF (ConvertToUTF32).
[cpp]void drawMidLine()
{
glBegin(GL_LINES);
glColor4f(1.0, 1.0, 1.0, 1.0);
float x = 0.1; // Create X and set it to 0.1
for (float y = -8; y < 8.1; y = y + 0.1) // Increase Y by 0.1 everytime until it gets too high
{
glVertex3f(x, y, 0.0); // Draw the point
if (x == 0.1)
x = -0.1; // If X is 0.1, set it to -0.1 for the next drawing
else
x = 0.1; // If X is -0.1, set it to 0.1 for the next drawing
}
glEnd();
}[/cpp]
I'm trying to make an alternating line like this:
\
/
\
/
\
/
That's the function I wrote for it. Instead it's doing this:
|
|
|
|
Any ideas?
Try the other axis?
[QUOTE=esalaka;23286583]Try the other axis?[/QUOTE]
I'll try that, it couldn't hurt. :v:
Could it? :ohdear:
[editline]07:08PM[/editline]
Nope, does the same thing but on the other axis.
Big surprise. :v:
[QUOTE=dArKnEsS_2;23286224][cpp]void drawMidLine()
{
glBegin(GL_LINES);
glColor4f(1.0, 1.0, 1.0, 1.0);
float x = 0.1; // Create X and set it to 0.1
for (float y = -8; y < 8.1; y = y + 0.1) // Increase Y by 0.1 everytime until it gets too high
{
glVertex3f(x, y, 0.0); // Draw the point
if (x == 0.1)
x = -0.1; // If X is 0.1, set it to -0.1 for the next drawing
else
x = 0.1; // If X is -0.1, set it to 0.1 for the next drawing
}
glEnd();
}[/cpp]
I'm trying to make an alternating line like this:
\
/
\
/
\
/
That's the function I wrote for it. Instead it's doing this:
|
|
|
|
Any ideas?[/QUOTE]
Float precision might be the problem. Try checking x>0 instead of x==0.1
Or <.9 && >.11.
Can anyone help me find a decent beginners Android book? I'd rather have one that's below my skill level, than above. I can always skip ahead. Android 2.0+ please. I wish O'Reilly had one out, they're usually my favourite. I'm off to bed, though. I've been looking for a while.
[QUOTE=dArKnEsS_2;23286224][cpp]void drawMidLine()
{
glBegin(GL_LINES);
glColor4f(1.0, 1.0, 1.0, 1.0);
float x = 0.1; // Create X and set it to 0.1
for (float y = -8; y < 8.1; y = y + 0.1) // Increase Y by 0.1 everytime until it gets too high
{
glVertex3f(x, y, 0.0); // Draw the point
if (x == 0.1)
x = -0.1; // If X is 0.1, set it to -0.1 for the next drawing
else
x = 0.1; // If X is -0.1, set it to 0.1 for the next drawing
}
glEnd();
}[/cpp]
I'm trying to make an alternating line like this:
\
/
\
/
\
/
That's the function I wrote for it. Instead it's doing this:
|
|
|
|
Any ideas?[/QUOTE]
Just me being annoying :v:
Use y += 0.1 instead of y = y + 0.1
And you can replace your if statements with x *= -1
or x = -x;
or x = x - (x * 2)
[QUOTE=Shadaez;23301605]Or <.9 && >.11.
Can anyone help me find a decent beginners Android book? I'd rather have one that's below my skill level, than above. I can always skip ahead. Android 2.0+ please. I wish O'Reilly had one out, they're usually my favourite. I'm off to bed, though. I've been looking for a while.[/QUOTE]
They are actually working on one: [url=http://androidcookbook.oreilly.com/home.seam]link[/url].
I got some simple questions, I'm still learning Java, and I am reading HeadFirst Java (great book). But I still have some questions I'd like to get answered.. By people.
[code]This method must return a result of type String[/code]Above is the message I get for this line of code:
[code]public String CheckYourself(String guessnumbers)[/code]It is for a simple guessing game. I don't quite understand it, is all.
Next question:
I guy on FP let me have some pseudo-code for his abandoned ASCII Hero. Uh, how would I apply this to Java?
[code]for i = 1 to 5
if (fret[i] == 1 AND array[i][tick] == 0) OR (fret[i] == 0 AND array[i][tick] == 1) then
return 0
endif
next
return 1[/code]
[quote]basically it checks if any of the one frets is not matching the current tick, and if so returns a 0. If everything's alright it return 1.[/quote]
[QUOTE=hey5000;23327470][code]This method must return a result of type String[/code]Above is the message I get for this line of code:
[code]public String CheckYourself(String guessnumbers)[/code]It is for a simple guessing game. I don't quite understand it, is all.[/QUOTE]
You've declared the function CheckYourself with a return type of String - which means it is expected to return a String value.
[QUOTE=hey5000;23327470]I got some simple questions, I'm still learning Java, and I am reading HeadFirst Java (great book). But I still have some questions I'd like to get answered.. By people.
[code]This method must return a result of type String[/code]Above is the message I get for this line of code:
[code]public String CheckYourself(String guessnumbers)[/code]It is for a simple guessing game. I don't quite understand it, is all.
Next question:
I guy on FP let me have some pseudo-code for his abandoned ASCII Hero. Uh, how would I apply this to Java?
[code]for i = 1 to 5
if (fret[i] == 1 AND array[i][tick] == 0) OR (fret[i] == 0 AND array[i][tick] == 1) then
return 0
endif
next
return 1[/code][/QUOTE]
Expanding on the above answer, you're declared your function as a String type, meaning it'll return a string.
But, you have "return 0" and "return 1". 0 and 1 are integers, not strings
Sorry, you need to Log In to post a reply to this thread.